Skip to content

Commit

Permalink
more sync. dotnet compiling finally!
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Dec 2, 2024
1 parent 6605e53 commit 002e24b
Show file tree
Hide file tree
Showing 26 changed files with 1,143 additions and 143 deletions.
43 changes: 38 additions & 5 deletions src/dotnet/RDK/rdk_content.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1982,27 +1982,55 @@ public static System.Drawing.Bitmap GenerateQuickContentPreview(RenderContent c,
return bitmap;
}

internal static ChangeContexts ChangeContextFromExtraRequirementsSetContext(ExtraRequirementsSetContexts sc) // Static.
/// <summary>Specifies optional buttons for ShowContentInstanceBrowser().</summary>
public enum ContentInstanceBrowserButtons
{
/// <summary>No optional buttons.</summary>
None = 0,
/// <summary>Include New button.</summary>
NewButton = 1,
/// <summary>Include Edit button.</summary>
EditButton = 2
}

/// <summary>
/// Allows the user to choose a content by displaying the Content Instance Browser dialog.
/// The dialog will have OK, Cancel and Help buttons, and optional New and Edit buttons.
/// <param name="doc">Specifies the document to use.</param>
/// <param name="instance_id">Sets the initially selected content and receives the instance id of the chosen content.</param>
/// <param name="kinds">Specifies the kind(s) of content that should be displayed in the browser.</param>
/// <param name="buttons">Specifies which optional buttons to display.</param>
/// Returns true if the user chooses a content or false if the dialog is cancelled.
/// </summary>
public static bool ShowContentInstanceBrowser(RhinoDoc doc, ref Guid instance_id, RenderContentKind kinds, ContentInstanceBrowserButtons buttons)
{
return UnsafeNativeMethods.Rdk_Globals_ShowContentInstanceBrowser(doc.RuntimeSerialNumber, ref instance_id, (uint)kinds, (uint)buttons);
}

internal static ChangeContexts ChangeContextFromExtraRequirementsSetContext(ExtraRequirementsSetContexts sc)
{
switch (sc)
{
case ExtraRequirementsSetContexts.UI: return ChangeContexts.UI;
case ExtraRequirementsSetContexts.Drop: return ChangeContexts.Drop;
case ExtraRequirementsSetContexts.UI: return ChangeContexts.UI;
case ExtraRequirementsSetContexts.Drop: return ChangeContexts.Drop;
default: break;
}

return ChangeContexts.Program;
}

internal static ExtraRequirementsSetContexts ExtraRequirementsSetContextFromChangeContext(ChangeContexts cc) // Static.
internal static ExtraRequirementsSetContexts ExtraRequirementsSetContextFromChangeContext(ChangeContexts cc)
{
switch (cc)
{
case ChangeContexts.UI: return ExtraRequirementsSetContexts.UI;
case ChangeContexts.UI: return ExtraRequirementsSetContexts.UI;
case ChangeContexts.Drop: return ExtraRequirementsSetContexts.Drop;
default: break;
}

return ExtraRequirementsSetContexts.Program;
}

static internal RenderContentChangeReason ReasonFromAttachReason(UnsafeNativeMethods.RdkEventWatcherBaseAttachReason reason)
{
switch (reason)
Expand All @@ -2015,9 +2043,12 @@ static internal RenderContentChangeReason ReasonFromAttachReason(UnsafeNativeMet
return RenderContentChangeReason.Open;
case UnsafeNativeMethods.RdkEventWatcherBaseAttachReason.Undo:
return RenderContentChangeReason.AttachUndo;
default: break;
}

throw new Exception("Unknown RdkEventWatcherBaseAttachReason type");
}

static internal RenderContentChangeReason ReasonFromDetachReason(UnsafeNativeMethods.RdkEventWatcherBaseDetachReason reason)
{
switch (reason)
Expand All @@ -2030,7 +2061,9 @@ static internal RenderContentChangeReason ReasonFromDetachReason(UnsafeNativeMet
return RenderContentChangeReason.Delete;
case UnsafeNativeMethods.RdkEventWatcherBaseDetachReason.Undo:
return RenderContentChangeReason.DetachUndo;
default: break;
}

throw new Exception("Unknown RdkEventWatcherBaseDetachReason type");
}

Expand Down
47 changes: 36 additions & 11 deletions src/dotnet/RDK/rdk_pep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#if RHINO_SDK
using DE = Rhino.RDK.Delegates;
using static Rhino.Render.RenderContent;
using Rhino.UI.Controls;
#endif

Expand Down Expand Up @@ -160,10 +159,23 @@ public enum PostEffectStyles : int
/// <since>7.0</since>
public enum PostEffectExecuteWhileRenderingOptions : int
{
None = 0, // OBSOLETE; typo. Use Never.
Never = 0, // The post effect does not support execution while rendering.
Always = 1, // The post effect supports execution while rendering and it should be run every time the dib is updated.
UseDelay = 2, // The post effect supports execution while rendering but only after a delay the first time.
None = 0, /// OBSOLETE; typo. Use Never.

/// The post effect does not support execution while rendering.
Never = 0,

/// The post effect supports execution while rendering and it should be run every time the dib
/// is updated.
Always = 1,

/// The post effect supports execution while rendering but only after a delay the first time.
UseDelay = 2,

/// <since>8.14</since>
/// The post effect supports execution while rendering but requires a PostEffectExecutionControl object
/// to be registered with the render window. The ReadyToExecutePostEffect() function on this object will
/// then be called to decide when to run the post effect.
UseExecutionControl = 3
};

public static class PostEffectUuids
Expand Down Expand Up @@ -401,6 +413,7 @@ private static PostEffect FromSerialNumber(int serial)
return null;
}

#if RHINO_SDK
internal static DE.CAN_EXECUTE_PROC can_execute_proc = CanExecute;
[MonoPInvokeCallback(typeof(DE.CAN_EXECUTE_PROC))]
private static int CanExecute(int serial, IntPtr pIRhRdkPostEffectPipeLine)
Expand Down Expand Up @@ -605,6 +618,7 @@ static internal void SetCppHooks(bool bInitialize)
null, null, null, null, null, null, null, null);
}
}
#endif

/// <since>7.0</since>
public static Type[] RegisterPostEffect(PlugIns.PlugIn plugin)
Expand Down Expand Up @@ -812,7 +826,7 @@ public override int GetHashCode() // [ANDYLOOK] This does not need to be virtual
}

/// <since>7.0</since>
public void BeginChange(ChangeContexts changeContext)
public void BeginChange(RenderContent.ChangeContexts changeContext)
{
UnsafeNativeMethods.IRhRdkPostEffect_BeginChange(CppPointer, (int)changeContext);

Expand Down Expand Up @@ -935,6 +949,8 @@ void Dispose(bool bDisposing)
m_cpp = IntPtr.Zero;
}
}

#if RHINO_SDK
/// <summary>
/// Add a section to the UI.
/// </summary>
Expand All @@ -944,6 +960,7 @@ public void AddSection(ICollapsibleSection section)
{
UnsafeNativeMethods.IRhRdkPostEffectUI_AddSection(m_cpp, section.CppPointer);
}
#endif
}

internal class PostEffectFactory : PostEffectFactoryBase
Expand Down Expand Up @@ -1016,6 +1033,7 @@ public Guid PlugInId()
return new Guid(uuid);
}

#if RHINO_SDK
internal static DE.NEW_POST_EFFECT_PROC new_posteffect_proc = NewPostEffect;
[MonoPInvokeCallback(typeof(DE.NEW_POST_EFFECT_PROC))]
private static IntPtr NewPostEffect(int serial)
Expand Down Expand Up @@ -1062,6 +1080,7 @@ static internal void SetCppHooks(bool bInitialize)
}
}
}
#endif

/// <since>7.0</since>
[Flags]
Expand Down Expand Up @@ -1570,6 +1589,7 @@ private static PostEffectJob FromSerialNumber(int serial)
/// <since>7.0</since>
public abstract bool Execute(Rectangle rect, PostEffectJobChannels access);

#if RHINO_SDK
internal static DE.CLONE_POST_EFFECT_JOB_PROC clone_proc = Clone;
[MonoPInvokeCallback(typeof(DE.CLONE_POST_EFFECT_JOB_PROC))]
private static IntPtr Clone(int serial)
Expand Down Expand Up @@ -1623,6 +1643,7 @@ static internal void SetCppHooks(bool bInitialize)
UnsafeNativeMethods.Rdk_CRdkCmnPostEffectJob_SetCallbacks(null, null, null);
}
}
#endif
}

public class PostEffectJobChannels : IDisposable
Expand Down Expand Up @@ -1921,7 +1942,7 @@ public override bool WriteState(ref PostEffectState state)
return UnsafeNativeMethods.IRhRdkPostEffect_WriteState(CppPointer, state.CppPointer);
}

new public void BeginChange(ChangeContexts changeContext)
new public void BeginChange(RenderContent.ChangeContexts changeContext)
{
UnsafeNativeMethods.IRhRdkPostEffect_BeginChange(CppPointer, (int)changeContext);
}
Expand Down Expand Up @@ -2275,7 +2296,7 @@ public abstract class PostEffectExecutionControl : IDisposable
{
internal int SerialNumber { get; set; }
internal IntPtr CppPointer { get; private set; }

#if RHINO_SDK
/// <since>8.0</since>
public PostEffectExecutionControl()
{
Expand All @@ -2287,7 +2308,7 @@ public PostEffectExecutionControl()
PostEffectExecutionControlList._list.Add(new WeakReference<PostEffectExecutionControl>(this));
}
}

#endif
~PostEffectExecutionControl()
{
Dispose(false);
Expand All @@ -2309,12 +2330,13 @@ public virtual void Dispose(bool bDisposing)
if (!disposed)
{
disposed = true;

#if RHINO_SDK
if (CppPointer != IntPtr.Zero)
{
UnsafeNativeMethods.CRdkCmnPostEffectExecutionControl_DeleteThis(CppPointer);
CppPointer = IntPtr.Zero;
}
#endif
}
}

Expand Down Expand Up @@ -2342,6 +2364,7 @@ public IntPtr Detach()
return p;
}

#if RHINO_SDK
internal static DE.POST_EFFECT_EXECUTION_CONTROL_PROC__DELETE_THIS delete_this_proc = DeleteThis;
[MonoPInvokeCallback(typeof(DE.POST_EFFECT_EXECUTION_CONTROL_PROC__DELETE_THIS))]
private static void DeleteThis(int serial)
Expand All @@ -2361,6 +2384,7 @@ private static bool ReadyToExecutePostEffect(int serial, Guid pep_id)
return client.ReadyToExecutePostEffect(pep_id);
}


static internal void SetCppHooks(bool bInitialize)
{
if (bInitialize)
Expand All @@ -2372,6 +2396,7 @@ static internal void SetCppHooks(bool bInitialize)
UnsafeNativeMethods.Rdk_CRdkCmnPostEffectExecutionControl_SetCallbacks(null, null);
}
}
}

#endif
}
}
13 changes: 11 additions & 2 deletions src/dotnet/UnsafeNativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ Rhino.Commands.SelCommand.SelSubObjectCallback selSubObjectCb
[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetLinetypeTableEventCallback(Rhino.RhinoDoc.RhinoTableCallback cb, Rhino.Runtime.HostUtils.ReportCallback reportCallback);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetHatchPatternTableEventCallback(Rhino.RhinoDoc.RhinoTableCallback cb, Rhino.Runtime.HostUtils.ReportCallback reportCallback);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetDimStyleTableEventCallback(Rhino.RhinoDoc.RhinoTableCallback cb, Rhino.Runtime.HostUtils.ReportCallback reportCallback);

Expand Down Expand Up @@ -379,10 +382,13 @@ internal static extern uint CRhinoDoc_AddCustomUndoEvent(uint docSerialNumber, [
[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetDetailEventCallback(Rhino.Display.RhinoPageView.PageViewCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetViewEnableDrawingCallback(Rhino.Display.RhinoView.ViewEnableDrawingCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetPageViewPropertiesCallback(Rhino.Display.RhinoPageView.PageViewPropertiesCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetDisplayModeChangedEventCallback(Rhino.Display.DisplayPipeline.DisplayModeChangedCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
Expand All @@ -392,7 +398,10 @@ internal static extern uint CRhinoDoc_AddCustomUndoEvent(uint docSerialNumber, [
internal static extern void CRhinoEventWatcher_SetOnIdleCallback(Rhino.RhinoApp.RhCmnEmptyCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetTransformObjectsCallback(Rhino.RhinoDoc.RhinoTransformObjectsCallback cb);
internal static extern void CRhinoEventWatcher_SetBeforeTransformObjectsCallback(Rhino.RhinoDoc.RhinoBeforeTransformObjectsCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetAfterTransformObjectsCallback(Rhino.RhinoDoc.RhinoAfterTransformObjectsCallback cb);

[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)]
internal static extern void CRhinoEventWatcher_SetOnMainLoopCallback(Rhino.RhinoApp.RhCmnEmptyCallback cb);
Expand Down
Loading

0 comments on commit 002e24b

Please sign in to comment.