From b39ae94480f9f4642fe2a2cba3dc01b152eb0a7b Mon Sep 17 00:00:00 2001 From: fraguada Date: Fri, 22 Nov 2024 14:26:36 +0100 Subject: [PATCH 1/7] first commit of 8.13 sync WIP --- src/dotnet/RDK/groundplane.cs | 1 + src/dotnet/RDK/rdk_content.cs | 297 +++- src/dotnet/RDK/rdk_decals.cs | 3 + src/dotnet/RDK/rdk_pep.cs | 160 ++- src/dotnet/RDK/safeframe.cs | 1 + src/dotnet/RDK/sun.cs | 1 + src/dotnet/UI/Localization.cs | 1 + src/dotnet/UnsafeNativeMethods.cs | 18 +- .../opennurbs/opennurbs_3dm_settings.cs | 63 + src/dotnet/opennurbs/opennurbs_archive.cs | 2 + src/dotnet/opennurbs/opennurbs_beam.cs | 2 + src/dotnet/opennurbs/opennurbs_bezier.cs | 3 + src/dotnet/opennurbs/opennurbs_brep.cs | 158 ++- src/dotnet/opennurbs/opennurbs_curve.cs | 248 +++- src/dotnet/opennurbs/opennurbs_defines.cs | 206 +++ src/dotnet/opennurbs/opennurbs_extensions.cs | 8 +- src/dotnet/opennurbs/opennurbs_fpoint.cs | 9 + src/dotnet/opennurbs/opennurbs_geometry.cs | 30 +- src/dotnet/opennurbs/opennurbs_hatch.cs | 32 +- src/dotnet/opennurbs/opennurbs_instance.cs | 38 + src/dotnet/opennurbs/opennurbs_intersect.cs | 91 +- src/dotnet/opennurbs/opennurbs_leader.cs | 3 +- src/dotnet/opennurbs/opennurbs_massprop.cs | 23 + src/dotnet/opennurbs/opennurbs_mesh.cs | 121 +- src/dotnet/opennurbs/opennurbs_object.cs | 2 +- .../opennurbs/opennurbs_planesurface.cs | 27 + src/dotnet/opennurbs/opennurbs_point.cs | 4 +- src/dotnet/opennurbs/opennurbs_pointcloud.cs | 9 +- .../opennurbs/opennurbs_polylinecurve.cs | 20 +- src/dotnet/opennurbs/opennurbs_rtree.cs | 30 + src/dotnet/opennurbs/opennurbs_subd.cs | 72 +- src/dotnet/opennurbs/opennurbs_texture.cs | 4 + src/dotnet/opennurbs/opennurbs_userdata.cs | 10 + src/dotnet/resolver.cs | 1 + src/dotnet/rhino/persistentsettingshooks.cs | 59 +- src/dotnet/rhino/rhinosdkadvancedsettings.cs | 1 + src/dotnet/rhino/rhinosdkapp.cs | 62 +- src/dotnet/rhino/rhinosdkappsettings.cs | 123 +- src/dotnet/rhino/rhinosdkcommand.cs | 39 +- src/dotnet/rhino/rhinosdkdetailobject.cs | 1 + src/dotnet/rhino/rhinosdkdimstyle.cs | 37 + src/dotnet/rhino/rhinosdkdisplaypipeline.cs | 30 + .../rhinosdkdisplaypipelineattributes.cs | 1215 ++++++++++++++++- src/dotnet/rhino/rhinosdkdoc.cs | 161 ++- src/dotnet/rhino/rhinosdkdocproperties.cs | 25 + src/dotnet/rhino/rhinosdkfont.cs | 2 + src/dotnet/rhino/rhinosdkgroup.cs | 6 + src/dotnet/rhino/rhinosdkhatchpattern.cs | 38 + src/dotnet/rhino/rhinosdkinstance.cs | 95 +- src/dotnet/rhino/rhinosdklayer.cs | 47 + src/dotnet/rhino/rhinosdklinetype.cs | 38 + src/dotnet/rhino/rhinosdkmeshobject.cs | 10 +- src/dotnet/rhino/rhinosdkmouse.cs | 154 ++- src/dotnet/rhino/rhinosdkobject.cs | 56 +- src/dotnet/rhino/rhinosdkobjectattributes.cs | 12 + src/dotnet/rhino/rhinosdkobjectmanager.cs | 119 +- .../rhinosdkobjectpropertiesdialogpage.cs | 40 + src/dotnet/rhino/rhinosdkpagelayoutview.cs | 35 + src/dotnet/rhino/rhinosdkplugin.cs | 59 +- src/dotnet/rhino/rhinosdkpointobject.cs | 61 +- src/dotnet/rhino/rhinosdkprintinfo.cs | 14 +- src/dotnet/rhino/rhinosdksnapshotsclient.cs | 24 + src/dotnet/rhino/rhinosdkstackeddialogpage.cs | 2 + src/dotnet/rhino/rhinosdkview.cs | 48 + src/dotnet/rhino/rhinosdkviewport.cs | 13 + src/librhino3dm_native/on_3dm_attributes.cpp | 8 + src/librhino3dm_native/on_3dm_settings.cpp | 50 + src/librhino3dm_native/on_arc.cpp | 2 +- src/librhino3dm_native/on_brep.cpp | 2 +- src/librhino3dm_native/on_curve.cpp | 17 + src/librhino3dm_native/on_defines.cpp | 2 +- .../on_hiddenlinedrawing.cpp | 5 +- src/librhino3dm_native/on_light.cpp | 2 +- src/librhino3dm_native/on_massprop.cpp | 8 + src/librhino3dm_native/on_material.cpp | 16 +- .../rhcommon_c/rhcommon_c_api.h | 6 +- 76 files changed, 4111 insertions(+), 331 deletions(-) diff --git a/src/dotnet/RDK/groundplane.cs b/src/dotnet/RDK/groundplane.cs index 19fed738e..235e419d1 100644 --- a/src/dotnet/RDK/groundplane.cs +++ b/src/dotnet/RDK/groundplane.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; +using Rhino.Runtime; using Rhino.Runtime.InteropWrappers; #pragma warning disable 1591 diff --git a/src/dotnet/RDK/rdk_content.cs b/src/dotnet/RDK/rdk_content.cs index cae041885..898036ae6 100644 --- a/src/dotnet/RDK/rdk_content.cs +++ b/src/dotnet/RDK/rdk_content.cs @@ -440,130 +440,130 @@ public enum RenderContentStyles : int public static class ContentUuids { /// 6.0 - public static Guid BasicMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBasicMaterialType); + public static Guid BasicMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBasicMaterialType); /// 6.0 - public static Guid BlendMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBlendMaterialType); + public static Guid BlendMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBlendMaterialType); /// 6.0 - public static Guid CompositeMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcCompositeMaterialType); + public static Guid CompositeMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcCompositeMaterialType); /// 6.0 - public static Guid PlasterMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPlasterMaterialType); + public static Guid PlasterMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPlasterMaterialType); /// 6.0 - public static Guid MetalMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcMetalMaterialType); + public static Guid MetalMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcMetalMaterialType); /// 6.0 - public static Guid PaintMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPaintMaterialType); + public static Guid PaintMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPaintMaterialType); /// 6.0 - public static Guid PlasticMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPlasticMaterialType); + public static Guid PlasticMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPlasticMaterialType); /// 6.0 - public static Guid GemMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGemMaterialType); + public static Guid GemMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGemMaterialType); /// 6.0 - public static Guid GlassMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGlassMaterialType); + public static Guid GlassMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGlassMaterialType); /// 6.0 - public static Guid PictureMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPictureMaterialType); + public static Guid PictureMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPictureMaterialType); /// 6.0 - public static Guid DefaultMaterialInstance => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcDefaultMaterialInstance); + public static Guid DefaultMaterialInstance => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcDefaultMaterialInstance); /// /// Rhino V8 Blend material type Guid /// /// 8.0 - public static Guid V8BlendMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcV8BlendMaterialType); + public static Guid V8BlendMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcV8BlendMaterialType); /// 7.0 - public static Guid PhysicallyBasedMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPhysicallyBasedMaterialType); + public static Guid PhysicallyBasedMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPhysicallyBasedMaterialType); /// 7.0 - public static Guid DoubleSidedMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcDoubleSidedMaterialType); + public static Guid DoubleSidedMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcDoubleSidedMaterialType); /// 7.0 - public static Guid EmissionMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcEmissionMaterialType); + public static Guid EmissionMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcEmissionMaterialType); /// 7.5 - public static Guid DisplayAttributeMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcDisplayAttributeMaterialType); + public static Guid DisplayAttributeMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcDisplayAttributeMaterialType); /// 6.0 - public static Guid RealtimeDisplayMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcRealtimeDisplayMaterialType); + public static Guid RealtimeDisplayMaterialType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcRealtimeDisplayMaterialType); /// 6.0 - public static Guid BasicEnvironmentType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBasicEnvironmentType); + public static Guid BasicEnvironmentType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBasicEnvironmentType); /// 6.0 - public static Guid DefaultEnvironmentInstance => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcDefaultEnvironmentInstance); + public static Guid DefaultEnvironmentInstance => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcDefaultEnvironmentInstance); /// 6.0 - public static Guid Texture2DCheckerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.Rc2DCheckerTextureType); + public static Guid Texture2DCheckerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.Rc2DCheckerTextureType); /// 6.0 - public static Guid Texture3DCheckerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.Rc3DCheckerTextureType); + public static Guid Texture3DCheckerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.Rc3DCheckerTextureType); /// 6.0 - public static Guid AdvancedDotTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcAdvancedDotTextureType); + public static Guid AdvancedDotTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcAdvancedDotTextureType); /// 6.0 - public static Guid BitmapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBitmapTextureType); + public static Guid BitmapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBitmapTextureType); /// 6.0 - public static Guid BlendTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBlendTextureType); + public static Guid BlendTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBlendTextureType); /// 6.0 - public static Guid CubeMapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcCubeMapTextureType); + public static Guid CubeMapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcCubeMapTextureType); /// 6.0 - public static Guid ExposureTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcExposureTextureType); + public static Guid ExposureTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcExposureTextureType); /// 6.0 - public static Guid FBmTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcFBmTextureType); + public static Guid FBmTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcFBmTextureType); /// 6.0 - public static Guid GradientTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGradientTextureType); + public static Guid GradientTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGradientTextureType); /// 6.0 - public static Guid GraniteTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGraniteTextureType); + public static Guid GraniteTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGraniteTextureType); /// 6.0 - public static Guid GridTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGridTextureType); + public static Guid GridTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGridTextureType); /// 6.0 - public static Guid HDRTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcHDRTextureType); + public static Guid HDRTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcHDRTextureType); /// 6.0 - public static Guid EXRTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcEXRTextureType); + public static Guid EXRTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcEXRTextureType); /// 6.0 - public static Guid MarbleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcMarbleTextureType); + public static Guid MarbleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcMarbleTextureType); /// 6.0 - public static Guid MaskTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcMaskTextureType); + public static Guid MaskTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcMaskTextureType); /// 6.0 - public static Guid NoiseTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcNoiseTextureType); + public static Guid NoiseTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcNoiseTextureType); /// 6.0 - public static Guid PerlinMarbleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPerlinMarbleTextureType); + public static Guid PerlinMarbleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPerlinMarbleTextureType); /// 6.0 - public static Guid PerturbingTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPerturbingTextureType); + public static Guid PerturbingTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPerturbingTextureType); /// 6.0 - public static Guid ProjectionChangerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcProjectionChangerTextureType); + public static Guid ProjectionChangerTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcProjectionChangerTextureType); /// 6.0 - public static Guid ResampleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcResampleTextureType); + public static Guid ResampleTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcResampleTextureType); /// 6.0 - public static Guid SingleColorTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcSingleColorTextureType); + public static Guid SingleColorTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcSingleColorTextureType); /// 6.0 - public static Guid SimpleBitmapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcSimpleBitmapTextureType); + public static Guid SimpleBitmapTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcSimpleBitmapTextureType); /// 6.0 - public static Guid StuccoTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcStuccoTextureType); + public static Guid StuccoTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcStuccoTextureType); /// 6.0 - public static Guid TextureAdjustmentTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcTextureAdjustmentTextureType); + public static Guid TextureAdjustmentTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcTextureAdjustmentTextureType); /// 6.0 - public static Guid TileTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcTileTextureType); + public static Guid TileTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcTileTextureType); /// 6.0 - public static Guid TurbulenceTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcTurbulenceTextureType); + public static Guid TurbulenceTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcTurbulenceTextureType); /// 6.0 - public static Guid WavesTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcWavesTextureType); + public static Guid WavesTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcWavesTextureType); /// 6.0 - public static Guid WoodTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcWoodTextureType); + public static Guid WoodTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcWoodTextureType); /// 8.0 - public static Guid AddTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcAddTextureType); + public static Guid AddTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcAddTextureType); /// 8.0 - public static Guid MultiplyTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcMultiplyTextureType); + public static Guid MultiplyTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcMultiplyTextureType); /// 8.0 - public static Guid PhysicalSkyTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcPhysicalSkyTextureType); + public static Guid PhysicalSkyTextureType => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcPhysicalSkyTextureType); /// 6.0 - public static Guid HatchBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcHatchBumpTexture); + public static Guid HatchBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcHatchBumpTexture); /// 6.0 - public static Guid CrossHatchBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcCrossHatchBumpTexture); + public static Guid CrossHatchBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcCrossHatchBumpTexture); /// 6.0 - public static Guid LeatherBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcLeatherBumpTexture); + public static Guid LeatherBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcLeatherBumpTexture); /// 6.0 - public static Guid WoodBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcWoodBumpTexture); + public static Guid WoodBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcWoodBumpTexture); /// 6.0 - public static Guid SpeckleBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcSpeckleBumpTexture); + public static Guid SpeckleBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcSpeckleBumpTexture); /// 6.0 - public static Guid GritBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcGritBumpTexture); + public static Guid GritBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcGritBumpTexture); /// 6.0 - public static Guid DotBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcDotBumpTexture); + public static Guid DotBumpTexture => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcDotBumpTexture); /// 6.0 - public static Guid BasicMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBasicMaterialCCI); + public static Guid BasicMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBasicMaterialCCI); /// 6.0 - public static Guid BlendMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBlendMaterialCCI); + public static Guid BlendMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBlendMaterialCCI); /// 6.0 - public static Guid CompositeMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcCompositeMaterialCCI); + public static Guid CompositeMaterialCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcCompositeMaterialCCI); /// 6.0 - public static Guid BasicEnvironmentCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.RenderContent_UuidIds.RcBasicEnvironmentCCI); + public static Guid BasicEnvironmentCCI => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.RcBasicEnvironmentCCI); } /// 6.0 @@ -1203,14 +1203,21 @@ public IEnumerator GetEnumerator() var iterator = Iterator(); if (iterator != null) { - var content = iterator.First(); - while (content != null) + // 4th June 2024 John Croudy, https://mcneel.myjetbrains.com/youtrack/issue/RH-82358 + // Use try..finally to make sure the iterator gets deleted even if the caller breaks out of the loop. + try { - yield return content; - content = iterator.Next(); + var content = iterator.First(); + while (content != null) + { + yield return content; + content = iterator.Next(); + } + } + finally + { + iterator.DeleteThis(); } - - iterator.DeleteThis(); } } } @@ -1383,12 +1390,21 @@ static internal RenderContentKind ConvertContentKind(UnsafeNativeMethods.CRhRdkC /// /// If this is a material, checks if it's in use and the rhino object is selected. /// Otherwise returns false. - /// /// + /// /// internal bool IsInUseBySelectedObject() { return UnsafeNativeMethods.Rdk_RenderContent_IsInUseBySelectedObject(CppPointer); } + + /// + /// Checks if this render content has the specified id. This is different to checking the id + /// directly because it also checks the members of texture proxies. + /// + internal bool HasId(Guid id) + { + return UnsafeNativeMethods.Rdk_RenderContent_HasId(ConstPointer(), id); + } #endregion #region statics @@ -1680,6 +1696,7 @@ public static RenderContent LoadFromFile(String filename) /// /// Used by SaveToFile /// + /// 8.6 public enum EmbedFilesChoice : int { /// @@ -1702,6 +1719,7 @@ public enum EmbedFilesChoice : int /// Full path to the file to be saved. /// /// The loaded content or null if an error occurred. + /// 8.6 public bool SaveToFile(String filename, EmbedFilesChoice embedFilesChoice) { return UnsafeNativeMethods.Rdk_RenderContent_SaveContentToFile(ConstPointer(), filename, (int)embedFilesChoice); @@ -1794,6 +1812,7 @@ public RenderContent MakeCopy() internal delegate void OnMakeCopyCallback(int serialNumber, IntPtr pNewContent); internal static OnMakeCopyCallback g_on_make_copy = OnMakeCopyImpl; + [MonoPInvokeCallback(typeof(OnMakeCopyCallback))] private static void OnMakeCopyImpl(int serialNumber, IntPtr pNewContent) { var content = FromSerialNumber(serialNumber); @@ -1881,6 +1900,88 @@ public static RenderContent FromXml(String xml, RhinoDoc doc) return RenderContent.FromPointer(pContent, null); } + /// + /// Generate a render content preview + /// + /// Linear Workflow + /// Render Content + /// Image width + /// Image height + /// Suppress Local Mapping + /// Preivew Job Signature + /// Preivew Appearance + /// Reference to PreviewRenderResult value + /// The Bitmap of the render content preview + public static System.Drawing.Bitmap GenerateRenderContentPreview(LinearWorkflow lwf, RenderContent c, int width, int height, bool bSuppressLocalMapping, PreviewJobSignature pjs, PreviewAppearance pa, ref Utilities.PreviewRenderResult result) + { + if (lwf == null || c == null || pjs == null || pa == null) + return null; + + result = Utilities.PreviewRenderResult.Nothing; + + uint rValue = 0; + + IntPtr pDib = UnsafeNativeMethods.Rdk_Globals_GenerateRenderedContentPreview(lwf.CppPointer, c.CppPointer, width, height, bSuppressLocalMapping, pjs.CppPointer, pa.CppPointer, ref rValue); + + if(rValue == 0) + result = Utilities.PreviewRenderResult.Rendering; + else if(rValue == 1) + result = Utilities.PreviewRenderResult.CacheOK; + else if(rValue == 2) + result = Utilities.PreviewRenderResult.CacheFail; + else if(rValue == 3) + result = Utilities.PreviewRenderResult.Nothing; + + if (pDib == IntPtr.Zero) + return null; + + if (rValue == (uint)Utilities.PreviewRenderResult.Rendering || rValue == (uint)Utilities.PreviewRenderResult.CacheFail || rValue == (uint)Utilities.PreviewRenderResult.Nothing) + return null; + + var bitmap = Rhino.Runtime.InteropWrappers.RhinoDib.ToBitmap(pDib, true); + return bitmap; + } + + /// + /// Generate a quick render content preview + /// + /// Render Content + /// Image width + /// Image height + /// PreviewSceneServer + /// SuppressLocalMapping + /// ContentChanged = 0, ViewChanged = 1, RefreshDisplay = 2, Other = 99 + /// Rhino.Command.Result value for successfull quick image creation + /// The Bitmap of the quick render content preview + public static System.Drawing.Bitmap GenerateQuickContentPreview(RenderContent c, int width, int height, PreviewSceneServer psc, bool bSuppressLocalMapping, int reason, ref Rhino.Commands.Result result) + { + uint rValue = 0; + result = Rhino.Commands.Result.Nothing; + + if (c == null) + return null; + + IntPtr pPreviewSceneServer = IntPtr.Zero; + if (psc != null) + pPreviewSceneServer = psc.CppPointer; + + IntPtr pDib = UnsafeNativeMethods.Rdk_Globals_GenerateQuickContentPreview(c.CppPointer, width, height, pPreviewSceneServer, bSuppressLocalMapping, reason, ref rValue); + + if(rValue == 0) + result = Rhino.Commands.Result.Nothing; + else if(rValue == 1) + result = Rhino.Commands.Result.Success; + + if (pDib == IntPtr.Zero) + return null; + + if (rValue == 0) + return null; + + var bitmap = Rhino.Runtime.InteropWrappers.RhinoDib.ToBitmap(pDib, true); + return bitmap; + } + internal static ChangeContexts ChangeContextFromExtraRequirementsSetContext(ExtraRequirementsSetContexts sc) // Static. { switch (sc) @@ -1957,6 +2058,7 @@ static internal RenderContentChangeReason ReasonFromDetachReason(UnsafeNativeMet /// by m_runtime_serial_number. /// static readonly Dictionary g_custom_content_dictionary = new Dictionary(); + static object g_custom_content_dictionary_lock = new object(); /// /// Rhino.Render.Fields FieldDictionary which provides access to setting /// and retrieving field values. @@ -2061,8 +2163,11 @@ internal RenderContent() // This constructor is being called because we have a custom .NET subclass if (IsCustomClassDefintion()) { - RuntimeSerialNumber = g_current_serial_number++; - g_custom_content_dictionary.Add(RuntimeSerialNumber, this); + lock(g_custom_content_dictionary_lock) + { + RuntimeSerialNumber = System.Threading.Interlocked.Increment(ref g_current_serial_number); + g_custom_content_dictionary.Add(RuntimeSerialNumber, this); + } } // Find the plug-in that registered this class type var type = GetType(); @@ -2493,6 +2598,7 @@ public uint RenderHashExclude(CrcRenderHashFlags flags, string excludeParameterN internal delegate uint RenderCrcCallback(int serialNumber, ulong rcrcFlags, IntPtr pString_excludeParameterNames); internal static readonly RenderCrcCallback g_on_render_crc = OnRenderCrc; + [MonoPInvokeCallback(typeof(RenderCrcCallback))] private static uint OnRenderCrc(int serialNumber, ulong rcrcFlags, IntPtr pString_excludeParameterNamese) { var render_content = FromSerialNumber(serialNumber); @@ -3052,7 +3158,8 @@ public DataSources.ContentFactory Factory() } /// 7.0 - public bool GetUnderlyingInstances(ref RenderContentCollection collection) + /// DO NOT CALL THIS FUNCTION IN NEW CODE. IT WILL BE DEPRECATED ASAP. + public bool GetUnderlyingInstances(ref RenderContentCollection collection) // TODO: JOHNC GetUnderlyingInstances { return UnsafeNativeMethods.Rdk_RenderContent_GetUnderlyingInstances(ConstPointer(), collection.CppPointer); } @@ -3917,6 +4024,7 @@ static internal RenderContent NewRenderContent(Guid typeId, Type isSubclassOf) internal delegate int IsFactoryProductAcceptableAsChildCallback(int serialNumber, IntPtr contentFactoryPointer, IntPtr pString_childSlotName); internal static IsFactoryProductAcceptableAsChildCallback IsFactoryProductAcceptableAsChildHook = OnIsFactoryProductAcceptableAsChild; + [MonoPInvokeCallback(typeof(IsFactoryProductAcceptableAsChildCallback))] static int OnIsFactoryProductAcceptableAsChild(int serialNumber, IntPtr contentFactoryPointer, IntPtr pString_childSlotName) { var content = FromSerialNumber(serialNumber); @@ -3955,6 +4063,7 @@ virtual public bool IsFactoryProductAcceptableAsChild(Guid kindId, string factor internal delegate int IsContentTypeAcceptableAsChildCallback(int serialNumber, Guid type, IntPtr pString_childSlotName); internal static IsContentTypeAcceptableAsChildCallback m_IsContentTypeAcceptableAsChild = OnIsContentTypeAcceptableAsChild; + [MonoPInvokeCallback(typeof(IsContentTypeAcceptableAsChildCallback))] static int OnIsContentTypeAcceptableAsChild(int serialNumber, Guid type, IntPtr pString_childSlotName) { try @@ -3972,6 +4081,7 @@ static int OnIsContentTypeAcceptableAsChild(int serialNumber, Guid type, IntPtr internal delegate void GetParameterCallback(int serialNumber, IntPtr pStringName, IntPtr pVariant); internal static GetParameterCallback m_GetParameter = OnGetParameter; + [MonoPInvokeCallback(typeof(GetParameterCallback))] static void OnGetParameter(int serialNumber, IntPtr pStringName, IntPtr pVariant) { try @@ -4033,6 +4143,7 @@ static private void InternalEmbeddedFilesCallback(int serialNumber, IntPtr resul internal delegate void SetEmbeddedFilesCallback(int serialNumber, IntPtr result); internal static SetEmbeddedFilesCallback g_embedded_files_callback = OnEmbeddedFilesCallback; + [MonoPInvokeCallback(typeof(SetEmbeddedFilesCallback))] static void OnEmbeddedFilesCallback(int serialNumber, IntPtr result) { // 22nd November 2022 John Croudy, https://mcneel.myjetbrains.com/youtrack/issue/RH-71480 @@ -4050,6 +4161,7 @@ static void OnEmbeddedFilesCallback(int serialNumber, IntPtr result) internal delegate void SetGetFilenameCallback(int serialNumber, IntPtr result); internal static SetGetFilenameCallback g_get_filename_callback = OnGetFilenameCallback; + [MonoPInvokeCallback(typeof(SetGetFilenameCallback))] static void OnGetFilenameCallback(int serialNumber, IntPtr result) { var content = FromSerialNumber(serialNumber); @@ -4065,6 +4177,7 @@ static void OnGetFilenameCallback(int serialNumber, IntPtr result) internal delegate bool SetSetFilenameCallback(int serialNumber, IntPtr pFilename); internal static SetSetFilenameCallback g_set_filename_callback = OnSetFilenameCallback; + [MonoPInvokeCallback(typeof(SetSetFilenameCallback))] static bool OnSetFilenameCallback(int serialNumber, IntPtr pFilename) { var content = FromSerialNumber(serialNumber); @@ -4080,6 +4193,7 @@ static bool OnSetFilenameCallback(int serialNumber, IntPtr pFilename) internal delegate void SetMetersToUnitsCallback(int serialNumber); internal static SetMetersToUnitsCallback g_meters_to_units_callback = OnMetersToUnitsCallback; + [MonoPInvokeCallback(typeof(SetMetersToUnitsCallback))] static void OnMetersToUnitsCallback(int serialNumber) { var content = FromSerialNumber(serialNumber); @@ -4094,6 +4208,7 @@ static void OnMetersToUnitsCallback(int serialNumber) internal delegate void SetUnitsToMetersCallback(int serialNumber); internal static SetUnitsToMetersCallback g_units_to_meters_callback = OnUnitsToMetersCallback; + [MonoPInvokeCallback(typeof(SetUnitsToMetersCallback))] static void OnUnitsToMetersCallback(int serialNumber) { var content = FromSerialNumber(serialNumber); @@ -4152,6 +4267,7 @@ public virtual string Filename internal delegate int SetParameterCallback(int serialNumber, IntPtr name, IntPtr value); internal static SetParameterCallback m_SetParameter = OnSetParameter; + [MonoPInvokeCallback(typeof(SetParameterCallback))] static int OnSetParameter(int serialNumber, IntPtr pString_name, IntPtr value) { try @@ -4173,6 +4289,7 @@ static int OnSetParameter(int serialNumber, IntPtr pString_name, IntPtr value) internal delegate int GetExtraRequirementParameterCallback(int serialNumber, IntPtr pString_paramName, IntPtr pString_extraRequirementName, IntPtr value); internal static GetExtraRequirementParameterCallback m_GetExtraRequirementParameter = OnGetExtraRequirementParameter; + [MonoPInvokeCallback(typeof(GetExtraRequirementParameterCallback))] static int OnGetExtraRequirementParameter(int serialNumber, IntPtr pString_paramName, IntPtr pString_extraRequirementName, IntPtr value) { try @@ -4199,6 +4316,7 @@ static int OnGetExtraRequirementParameter(int serialNumber, IntPtr pString_param internal delegate int SetContentIconCallback(int serialNumber, int width, int height, IntPtr dibOut, int fromBaseClass); internal static SetContentIconCallback SetContentIcon = OnSetContentIcon; + [MonoPInvokeCallback(typeof(SetContentIconCallback))] private static int OnSetContentIcon(int serialNumber, int width, int height, IntPtr dibOut, int fromBaseClass) { try @@ -4298,6 +4416,7 @@ virtual public bool DynamicIcon(Size size, out Bitmap bitmap, DynamicIconUsage u internal delegate int SetExtraRequirementParameterCallback(int serialNumber, IntPtr pString_paramName, IntPtr pString_extraRequirementName, IntPtr value, int sc); internal static SetExtraRequirementParameterCallback m_SetExtraRequirementParameter = OnSetExtraRequirementParameter; + [MonoPInvokeCallback(typeof(SetExtraRequirementParameterCallback))] static int OnSetExtraRequirementParameter(int serialNumber, IntPtr pString_paramName, IntPtr pString_extraRequirementName, IntPtr value, int sc) { try @@ -4320,6 +4439,7 @@ static int OnSetExtraRequirementParameter(int serialNumber, IntPtr pString_param internal delegate int HarvestDataCallback(int serialNumber, IntPtr oldContent); internal static HarvestDataCallback HarvestData = g_on_harvest_data; + [MonoPInvokeCallback(typeof(HarvestDataCallback))] static int g_on_harvest_data(int serialNumber, IntPtr oldContent) { try @@ -4339,6 +4459,7 @@ static int g_on_harvest_data(int serialNumber, IntPtr oldContent) internal delegate void AddUiSectionsCallback(int serialNumber, Guid editorId); internal static AddUiSectionsCallback m_AddUISections = OnAddUISections; internal static Guid OnAddUiSectionsUIId = Guid.Empty; + [MonoPInvokeCallback(typeof(AddUiSectionsCallback))] static void OnAddUISections(int serialNumber, Guid UIId) { OnAddUiSectionsUIId = UIId; @@ -4356,6 +4477,7 @@ static void OnAddUISections(int serialNumber, Guid UIId) internal delegate int GetDefaultsFromUserCallback(int serialNumber); internal static GetDefaultsFromUserCallback GetDefaultsFromUser = g_on_get_defaults_from_user; + [MonoPInvokeCallback(typeof(GetDefaultsFromUserCallback))] static int g_on_get_defaults_from_user(int serialNumber) { try @@ -4373,6 +4495,7 @@ static int g_on_get_defaults_from_user(int serialNumber) internal delegate void RenderContentOnCppDtorCallback(int serialNumber); internal static RenderContentOnCppDtorCallback OnCppDtor = OnCppDtorRhCmnRenderContent; + [MonoPInvokeCallback(typeof(RenderContentOnCppDtorCallback))] static void OnCppDtorRhCmnRenderContent(int serialNumber) { try @@ -4393,6 +4516,7 @@ static void OnCppDtorRhCmnRenderContent(int serialNumber) internal delegate uint RenderContentBitFlagsCallback(int serialNumber, uint flags); internal static RenderContentBitFlagsCallback BitFlags = OnContentBitFlags; + [MonoPInvokeCallback(typeof(RenderContentBitFlagsCallback))] static uint OnContentBitFlags(int serialNumber, uint flags) { try @@ -4437,6 +4561,7 @@ protected void ModifyRenderContentStyles(RenderContentStyles stylesToAdd, Render internal delegate void GetRenderContentStringCallback(int serialNumber, int string_id, IntPtr pON_wString); internal static GetRenderContentStringCallback GetRenderContentString = OnGetRenderContentString; + [MonoPInvokeCallback(typeof(GetRenderContentStringCallback))] static void OnGetRenderContentString(int serialNnumber, int string_id, IntPtr pOnWString) { try @@ -4471,6 +4596,7 @@ static void OnGetRenderContentString(int serialNnumber, int string_id, IntPtr pO internal delegate IntPtr GetShaderCallback(int serialNumber, Guid renderEngineId, IntPtr privateData); internal static GetShaderCallback m_GetShader = OnGetShader; + [MonoPInvokeCallback(typeof(GetShaderCallback))] static IntPtr OnGetShader(int serialNumber, Guid renderEngineId, IntPtr privateData) { try @@ -4488,6 +4614,7 @@ static IntPtr OnGetShader(int serialNumber, Guid renderEngineId, IntPtr privateD internal delegate ulong RenderContentUiHashCallback(int serialNumber); internal static readonly RenderContentUiHashCallback m_GetUiHash = OnRenderContentUiHash; + [MonoPInvokeCallback(typeof(RenderContentUiHashCallback))] private static ulong OnRenderContentUiHash(int serialNumber) { var render_content = FromSerialNumber(serialNumber); @@ -4514,6 +4641,7 @@ private static ulong OnRenderContentUiHash(int serialNumber) internal delegate void CurrentContentChangedCallback(uint docSerialNumber, int kind, int usage, IntPtr pContent); private static ContentAddedCallback m_OnContentAdded; + [MonoPInvokeCallback(typeof(ContentAddedCallback))] private static void OnContentAdded(uint docSerialNumber, IntPtr pContent, UnsafeNativeMethods.RdkEventWatcherBaseAttachReason reason) { if (m_content_added_event != null) @@ -4526,6 +4654,7 @@ private static void OnContentAdded(uint docSerialNumber, IntPtr pContent, Unsafe internal static EventHandler m_content_added_event; private static ContentRenamedCallback m_OnContentRenamed; + [MonoPInvokeCallback(typeof(ContentRenamedCallback))] private static void OnContentRenamed(IntPtr pContent) { if (g_content_renamed_event != null) @@ -4538,6 +4667,7 @@ private static void OnContentRenamed(IntPtr pContent) static EventHandler g_content_renamed_event; private static ContentDeletingCallback m_OnContentDeleting; + [MonoPInvokeCallback(typeof(ContentDeletingCallback))] private static void OnContentDeleting(uint docSerialNumber, IntPtr pContent, UnsafeNativeMethods.RdkEventWatcherBaseDetachReason reason) { if (g_content_deleting_event != null) @@ -4550,6 +4680,7 @@ private static void OnContentDeleting(uint docSerialNumber, IntPtr pContent, Uns static EventHandler g_content_deleting_event; private static ContentDeletingCallback m_OnContentDeleted; + [MonoPInvokeCallback(typeof(ContentDeletingCallback))] private static void OnContentDeleted(uint docSerialNumber, IntPtr pContent, UnsafeNativeMethods.RdkEventWatcherBaseDetachReason reason) { if (g_content_deleted_event != null) @@ -4562,6 +4693,7 @@ private static void OnContentDeleted(uint docSerialNumber, IntPtr pContent, Unsa static EventHandler g_content_deleted_event; private static ContentReplacingCallback m_OnContentReplacing; + [MonoPInvokeCallback(typeof(ContentReplacingCallback))] private static void OnContentReplacing(uint docSerialNumber, IntPtr pContent) { if (g_content_replacing_event != null) @@ -4574,6 +4706,7 @@ private static void OnContentReplacing(uint docSerialNumber, IntPtr pContent) static EventHandler g_content_replacing_event; private static ContentReplacedCallback m_OnContentReplaced; + [MonoPInvokeCallback(typeof(ContentReplacedCallback))] private static void OnContentReplaced(uint docSerialNumber, IntPtr pContent) { if (g_content_replaced_event != null) @@ -4586,6 +4719,7 @@ private static void OnContentReplaced(uint docSerialNumber, IntPtr pContent) static EventHandler g_content_replaced_event; private static ContentChangedCallback m_OnContentChanged; + [MonoPInvokeCallback(typeof(ContentChangedCallback))] private static void OnContentChanged(IntPtr newContent, IntPtr oldContent, int cc) { if (g_content_changed_event != null) @@ -4599,6 +4733,7 @@ private static void OnContentChanged(IntPtr newContent, IntPtr oldContent, int c static EventHandler g_content_changed_event; private static ContentUpdatePreviewCallback m_OnContentUpdatePreview; + [MonoPInvokeCallback(typeof(ContentUpdatePreviewCallback))] private static void OnContentUpdatePreview(IntPtr pContent) { if (g_content_update_preview_event != null) @@ -4819,6 +4954,7 @@ public static event EventHandler PreviewRendered internal delegate void OnPreviewRenderedCallback(IntPtr pDib, uint quality, IntPtr pjs); internal static OnPreviewRenderedCallback g_on_preview_rendered; static EventHandler g_on_preview_rendered_event; + [MonoPInvokeCallback(typeof(OnPreviewRenderedCallback))] private static void OnPreviewRendered(IntPtr pDib, uint quality, IntPtr p_pjs) { if (g_on_preview_rendered_event != null) @@ -4827,7 +4963,7 @@ private static void OnPreviewRendered(IntPtr pDib, uint quality, IntPtr p_pjs) PreviewJobSignature pjs = new PreviewJobSignature(p_pjs); - var bitmap = Rhino.Runtime.InteropWrappers.RhinoDib.ToBitmap(pDib, true); + var bitmap = Rhino.Runtime.InteropWrappers.RhinoDib.ToBitmap(UnsafeNativeMethods.CRhinoDib_Copy(pDib), true); args.PreviewJobSignature = pjs; args.Bitmap = bitmap; @@ -4879,6 +5015,7 @@ public static event EventHandler ContentFiel internal delegate void OnContentFieldChangedCallback(int serialNumber, IntPtr pString_name, IntPtr value, int cc); internal static OnContentFieldChangedCallback g_on_content_field_changed; static EventHandler g_content_field_changed_event; + [MonoPInvokeCallback(typeof(OnContentFieldChangedCallback))] private static void OnContentFieldChanged(int serialNumber, IntPtr pString_name, IntPtr value, int cc) { if (g_content_field_changed_event != null) @@ -4922,6 +5059,7 @@ public static event EventHandler ContentUpdatePreview static EventHandler g_current_environment_change_event; private static CurrentContentChangedCallback m_OnCurrentEnvironmentChange; + [MonoPInvokeCallback(typeof(CurrentContentChangedCallback))] private static void OnCurrentEnvironmentChange(uint docSerialNumber, int kind, int usage, IntPtr pContent) { if (g_current_environment_change_event != null) @@ -4973,8 +5111,11 @@ internal bool AutoDelete internal static RenderContent FromSerialNumber(int serialNumber) { - g_custom_content_dictionary.TryGetValue(serialNumber, out RenderContent rc); - return rc; + lock (g_custom_content_dictionary_lock) + { + g_custom_content_dictionary.TryGetValue(serialNumber, out RenderContent rc); + return rc; + } } internal virtual IntPtr ConstPointer() @@ -5036,7 +5177,10 @@ protected virtual void Dispose(bool disposing) if (serialNumber >= 0) { RuntimeSerialNumber = -1; - g_custom_content_dictionary.Remove(serialNumber); + lock (g_custom_content_dictionary_lock) + { + g_custom_content_dictionary.Remove(serialNumber); + } } if (HostUtils.RunningOnWindows) @@ -5237,16 +5381,19 @@ public class PreviewRenderedEventArgs : EventArgs /// /// The Preview Job Signature associated with the rendered preview /// + /// 8.8 public PreviewJobSignature PreviewJobSignature { get { return m_preview_job_signature; } set { m_preview_job_signature = value;}} /// /// The Bitmap of the rendered preview /// + /// 8.8 public Bitmap Bitmap { get { return m_bitmap; } set { m_bitmap = value;}} /// /// The Bitmap of the rendered preview /// + /// 8.8 public Utilities.PreviewQuality Quality { get { return m_quality; } set { m_quality = value;}} } diff --git a/src/dotnet/RDK/rdk_decals.cs b/src/dotnet/RDK/rdk_decals.cs index 37a972c2a..279e627c7 100644 --- a/src/dotnet/RDK/rdk_decals.cs +++ b/src/dotnet/RDK/rdk_decals.cs @@ -172,6 +172,7 @@ public uint TextureRenderCRC(TextureRenderHashFlags rh, LinearWorkflow lw) /// Get the texture render hash for the referenced texture using the specified CrcRenderHashFlags. /// /// 8.0 + /// 8.5 [CLSCompliant(false)] [Obsolete("Do not use")] public uint TextureRenderHash(CrcRenderHashFlags flags) @@ -188,6 +189,7 @@ public uint TextureRenderHash(CrcRenderHashFlags flags) /// and linear workflow. /// /// 8.0 + /// 8.5 [CLSCompliant(false)] [Obsolete("Do not use")] public uint TextureRenderHash(CrcRenderHashFlags flags, LinearWorkflow lw) @@ -461,6 +463,7 @@ internal static List ConvertToNamedValueList(IntPtr parms) // [MARKE /// the UV on the texture that the color point was read from. /// true if the given point hits the decal, else false. /// 5.10 + /// 8.5 [Obsolete("Incredibly slow call")] public bool TryGetColor(Rhino.Geometry.Point3d point, Rhino.Geometry.Vector3d normal, ref Rhino.Display.Color4f colInOut, ref Rhino.Geometry.Point2d uvOut) { diff --git a/src/dotnet/RDK/rdk_pep.cs b/src/dotnet/RDK/rdk_pep.cs index 7636960b4..26332f7ef 100644 --- a/src/dotnet/RDK/rdk_pep.cs +++ b/src/dotnet/RDK/rdk_pep.cs @@ -160,11 +160,41 @@ public enum PostEffectStyles : int /// 7.0 public enum PostEffectExecuteWhileRenderingOptions : int { - None = 0, // The post effect does not support execution while rendering. + 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. }; + public static class PostEffectUuids + { + public static Guid Glare => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Glare); + public static Guid Bloom => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Bloom); + public static Guid Glow => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Glow); + public static Guid Fog => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Fog); + public static Guid DepthOfField => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_DepthOfField); + public static Guid Multiplier => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Multiplier); + public static Guid Noise => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Noise); + public static Guid GaussianBlur => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_GaussianBlur); + + public static Guid WireframePointsRGBA => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_WireframePointsRGBA); + public static Guid WireframeCurvesRGBA => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_WireframeCurvesRGBA); + public static Guid WireframeIsocurvesRGBA => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_WireframeIsocurvesRGBA); + public static Guid WireframeAnnotationsRGBA => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_WireframeAnnotationsRGBA); + + public static Guid ToneMapper_Clamp => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_ToneMapper_Clamp); + public static Guid ToneMapper_BlackWhitePoint => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_ToneMapper_BlackWhitePoint); + public static Guid ToneMapper_Logarithmic => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_ToneMapper_Logarithmic); + public static Guid ToneMapper_FalseColor => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_ToneMapper_FalseColor); + public static Guid ToneMapper_Filmic => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_ToneMapper_Filmic); + + public static Guid Gamma => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Gamma); + public static Guid Dithering => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Dithering); + public static Guid Watermark => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_Watermark); + public static Guid HueSatLum => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_HueSatLum); + public static Guid BriCon => UnsafeNativeMethods.RhRdkUuids_GetUuid(UnsafeNativeMethods.Rdk_UuidIds.PostEffect_BriCon); + } + public abstract class PostEffect : IDisposable { private int m_sn; @@ -372,6 +402,7 @@ private static PostEffect FromSerialNumber(int serial) } internal static DE.CAN_EXECUTE_PROC can_execute_proc = CanExecute; + [MonoPInvokeCallback(typeof(DE.CAN_EXECUTE_PROC))] private static int CanExecute(int serial, IntPtr pIRhRdkPostEffectPipeLine) { var client = FromSerialNumber(serial); @@ -384,6 +415,7 @@ private static int CanExecute(int serial, IntPtr pIRhRdkPostEffectPipeLine) } internal static DE.REQUIRED_CHANNELS_PROC required_channels_proc = GetRequiredChannels; + [MonoPInvokeCallback(typeof(DE.REQUIRED_CHANNELS_PROC))] private static void GetRequiredChannels(int serial, IntPtr pOnSimpleArrayUuid) { var client = FromSerialNumber(serial); @@ -399,6 +431,7 @@ private static void GetRequiredChannels(int serial, IntPtr pOnSimpleArrayUuid) } internal static DE.DELETE_THIS_PROC delete_this_proc = DeleteThis; + [MonoPInvokeCallback(typeof(DE.DELETE_THIS_PROC))] private static void DeleteThis(int serial) { var client = FromSerialNumber(serial); @@ -411,6 +444,7 @@ private static void DeleteThis(int serial) } internal static DE.READ_FROM_DOCUMENT_DEFAULTS_PROC read_from_document_defaults_proc = ReadFromDocumentDefaults; + [MonoPInvokeCallback(typeof(DE.READ_FROM_DOCUMENT_DEFAULTS_PROC))] private static int ReadFromDocumentDefaults(int serial, uint doc_serial) { //var client = FromSerialNumber(serial); @@ -423,6 +457,7 @@ private static int ReadFromDocumentDefaults(int serial, uint doc_serial) } internal static DE.WRITE_TO_DOCUMENT_DEFAULTS_PROC write_to_document_defaults_proc = WriteToDocumentDefaults; + [MonoPInvokeCallback(typeof(DE.WRITE_TO_DOCUMENT_DEFAULTS_PROC))] private static int WriteToDocumentDefaults(int serial, uint doc_serial) { //var client = FromSerialNumber(serial); @@ -446,6 +481,7 @@ private static int WriteToDocumentDefaults(int serial, uint doc_serial) // Remember to change IntPtr to real instance internal static DE.EXECUTE_PROC execute_proc = Execute; + [MonoPInvokeCallback(typeof(DE.EXECUTE_PROC))] private static int Execute(int serial, IntPtr pIRhRdkPostEffectPipeline, int left, int top, int width, int height) { var client = FromSerialNumber(serial); @@ -459,6 +495,7 @@ private static int Execute(int serial, IntPtr pIRhRdkPostEffectPipeline, int lef } internal static DE.GET_PARAM_PROC get_param_proc = GetParam; + [MonoPInvokeCallback(typeof(DE.GET_PARAM_PROC))] private static int GetParam(int serial, IntPtr pString, IntPtr pVariant) { var client = FromSerialNumber(serial); @@ -479,6 +516,7 @@ private static int GetParam(int serial, IntPtr pString, IntPtr pVariant) } internal static DE.SET_PARAM_PROC set_param_proc = SetParam; + [MonoPInvokeCallback(typeof(DE.SET_PARAM_PROC))] private static int SetParam(int serial, IntPtr pString, IntPtr pVariant) { var client = FromSerialNumber(serial); @@ -492,6 +530,7 @@ private static int SetParam(int serial, IntPtr pString, IntPtr pVariant) } internal static DE.READ_STATE_PROC read_state_proc = ReadState; + [MonoPInvokeCallback(typeof(DE.READ_STATE_PROC))] private static int ReadState(int serial, IntPtr pState) { var client = FromSerialNumber(serial); @@ -504,6 +543,7 @@ private static int ReadState(int serial, IntPtr pState) } internal static DE.WRITE_STATE_PROC write_state_proc = WriteState; + [MonoPInvokeCallback(typeof(DE.WRITE_STATE_PROC))] private static int WriteState(int serial, IntPtr pState) { var client = FromSerialNumber(serial); @@ -516,6 +556,7 @@ private static int WriteState(int serial, IntPtr pState) } internal static DE.RESET_TO_FACTORY_DEFAULTS_PROC reset_to_factory_defaults_proc = ResetToFactoryDefaults; + [MonoPInvokeCallback(typeof(DE.RESET_TO_FACTORY_DEFAULTS_PROC))] private static void ResetToFactoryDefaults(int serial) { var client = FromSerialNumber(serial); @@ -523,6 +564,7 @@ private static void ResetToFactoryDefaults(int serial) } internal static DE.ADD_UI_SECTIONS_PROC add_ui_sections_proc = AddUISections; + [MonoPInvokeCallback(typeof(DE.ADD_UI_SECTIONS_PROC))] private static void AddUISections(int serial, IntPtr pIRhRdkPostEffecsUI) { var client = FromSerialNumber(serial); @@ -534,6 +576,7 @@ private static void AddUISections(int serial, IntPtr pIRhRdkPostEffecsUI) } internal static DE.DISPLAY_HELP_PROC display_help_proc = DisplayHelp; + [MonoPInvokeCallback(typeof(DE.DISPLAY_HELP_PROC))] private static int DisplayHelp(int serial) { var client = FromSerialNumber(serial); @@ -974,6 +1017,7 @@ public Guid PlugInId() } internal static DE.NEW_POST_EFFECT_PROC new_posteffect_proc = NewPostEffect; + [MonoPInvokeCallback(typeof(DE.NEW_POST_EFFECT_PROC))] private static IntPtr NewPostEffect(int serial) { if (InternalRdkViewModelFactory.m_factories.ContainsKey(serial)) @@ -992,6 +1036,7 @@ private static IntPtr NewPostEffect(int serial) } internal static DE.PEP_UUID_PROC plugin_id_proc = PlugInId; + [MonoPInvokeCallback(typeof(DE.PEP_UUID_PROC))] private static Guid PlugInId(int serial) { if (InternalRdkViewModelFactory.m_factories.ContainsKey(serial)) @@ -1526,6 +1571,7 @@ private static PostEffectJob FromSerialNumber(int serial) public abstract bool Execute(Rectangle rect, PostEffectJobChannels access); 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) { var client = FromSerialNumber(serial); @@ -1545,6 +1591,7 @@ private static IntPtr Clone(int serial) } internal static DE.DELETE_THIS_POST_EFFECT_JOB delete_this_proc = DeleteThis; + [MonoPInvokeCallback(typeof(DE.DELETE_THIS_POST_EFFECT_JOB))] private static void DeleteThis(int serial) { var client = FromSerialNumber(serial); @@ -1553,6 +1600,7 @@ private static void DeleteThis(int serial) // Kom ihåg att byta pPixels.... internal static DE.EXECUTE_POST_EFFECT_JOB execute_proc = Execute; + [MonoPInvokeCallback(typeof(DE.EXECUTE_POST_EFFECT_JOB))] private static int Execute(int serial, int left, int top, int width, int height, IntPtr pAccess) { var client = FromSerialNumber(serial); @@ -2216,4 +2264,114 @@ internal IntPtr FindPostEffect(Guid id) return UnsafeNativeMethods.ON_PostEffects_PostEffectFromId(CppPointer, id); } } + + internal class PostEffectExecutionControlList + { + public static int serial_number = 0; + public static List> _list = new List>(); + } + + public abstract class PostEffectExecutionControl : IDisposable + { + internal int SerialNumber { get; set; } + internal IntPtr CppPointer { get; private set; } + + /// 8.0 + public PostEffectExecutionControl() + { + lock (PostEffectExecutionControlList._list) + { + SerialNumber = PostEffectExecutionControlList.serial_number; + CppPointer = UnsafeNativeMethods.CRdkCmnPostEffectExecutionControl_New(SerialNumber); + PostEffectExecutionControlList.serial_number++; + PostEffectExecutionControlList._list.Add(new WeakReference(this)); + } + } + + ~PostEffectExecutionControl() + { + Dispose(false); + } + + public abstract bool ReadyToExecutePostEffect(Guid pep_id); + + private bool disposed = false; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + /// 8.0 + public virtual void Dispose(bool bDisposing) + { + if (!disposed) + { + disposed = true; + + if (CppPointer != IntPtr.Zero) + { + UnsafeNativeMethods.CRdkCmnPostEffectExecutionControl_DeleteThis(CppPointer); + CppPointer = IntPtr.Zero; + } + } + } + + private static PostEffectExecutionControl FromSerialNumber(int serial) + { + lock (PostEffectExecutionControlList._list) + { + foreach (var item in PostEffectExecutionControlList._list) + { + if (item.TryGetTarget(out var ec)) + { + if (ec.SerialNumber == serial) + return ec; + } + } + } + + return null; + } + + public IntPtr Detach() + { + var p = CppPointer; + CppPointer = IntPtr.Zero; + return p; + } + + 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) + { + var client = FromSerialNumber(serial); + client?.Dispose(); + } + + internal static DE.POST_EFFECT_EXECUTION_CONTROL_PROC__READY_TO_EXECUTE ready_to_execute_proc = ReadyToExecutePostEffect; + [MonoPInvokeCallback(typeof(DE.POST_EFFECT_EXECUTION_CONTROL_PROC__READY_TO_EXECUTE))] + private static bool ReadyToExecutePostEffect(int serial, Guid pep_id) + { + var client = FromSerialNumber(serial); + if (client == null) + return false; + + return client.ReadyToExecutePostEffect(pep_id); + } + + static internal void SetCppHooks(bool bInitialize) + { + if (bInitialize) + { + UnsafeNativeMethods.Rdk_CRdkCmnPostEffectExecutionControl_SetCallbacks(delete_this_proc, ready_to_execute_proc); + } + else + { + UnsafeNativeMethods.Rdk_CRdkCmnPostEffectExecutionControl_SetCallbacks(null, null); + } + } + } + } diff --git a/src/dotnet/RDK/safeframe.cs b/src/dotnet/RDK/safeframe.cs index a0deb02af..95fa8b83d 100644 --- a/src/dotnet/RDK/safeframe.cs +++ b/src/dotnet/RDK/safeframe.cs @@ -1,4 +1,5 @@ +using Rhino.Runtime; using System; namespace Rhino.Render diff --git a/src/dotnet/RDK/sun.cs b/src/dotnet/RDK/sun.cs index 75d868610..4dd913e96 100644 --- a/src/dotnet/RDK/sun.cs +++ b/src/dotnet/RDK/sun.cs @@ -1,6 +1,7 @@ using System; using System.Diagnostics; +using Rhino.Runtime; #if RHINO_SDK using Rhino.UI.Controls; diff --git a/src/dotnet/UI/Localization.cs b/src/dotnet/UI/Localization.cs index 315bb0b3c..1fac85f15 100644 --- a/src/dotnet/UI/Localization.cs +++ b/src/dotnet/UI/Localization.cs @@ -488,6 +488,7 @@ internal static void SetHooks() } internal delegate void SetCurrentLanguageIdDelegate(int localeId); internal static readonly SetCurrentLanguageIdDelegate g_set_current_language_id = SetCurrentLanguageId; + [MonoPInvokeCallback(typeof(SetCurrentLanguageIdDelegate))] private static void SetCurrentLanguageId(int localeId) { g_language_id = localeId; diff --git a/src/dotnet/UnsafeNativeMethods.cs b/src/dotnet/UnsafeNativeMethods.cs index 419716bb4..17d27f59c 100644 --- a/src/dotnet/UnsafeNativeMethods.cs +++ b/src/dotnet/UnsafeNativeMethods.cs @@ -212,7 +212,7 @@ internal static extern void CRhinoRenderPlugIn_SetRdkCallbacks( Rhino.PlugIns.RenderPlugIn.RenderSettingsSectionsCallback renderSettingsSections, Rhino.PlugIns.RenderPlugIn.PlugInIconCallback pluginiconcallback, Rhino.PlugIns.RenderPlugIn.InitialChannelToDisplayCallback initialChannelToDisplay, - Rhino.PlugIns.RenderPlugIn.PlugInTextureNeedsBakingCallback pluginTextureNeedsBakingCallback, + Rhino.PlugIns.RenderPlugIn.PlugInIsTextureSupportedCallback pluginIsTextureSupportedCallback, Rhino.PlugIns.RenderPlugIn.CustomChannelNameCallback customChannelName ); @@ -380,6 +380,9 @@ internal static extern uint CRhinoDoc_AddCustomUndoEvent(uint docSerialNumber, [ internal static extern void CRhinoEventWatcher_SetDetailEventCallback(Rhino.Display.RhinoPageView.PageViewCallback cb); [DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)] + internal static extern void CRhinoEventWatcher_SetPageViewPropertiesCallback(Rhino.Display.RhinoPageView.PageViewPropertiesCallback cb); + +[DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)] internal static extern void CRhinoEventWatcher_SetDisplayModeChangedEventCallback(Rhino.Display.DisplayPipeline.DisplayModeChangedCallback cb); [DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)] @@ -846,6 +849,13 @@ internal static extern void Rdk_CRdkCmnPostEffectJob_SetCallbacks( Rhino.RDK.Delegates.EXECUTE_POST_EFFECT_JOB execute ); + // CmnPostEffectExecutionControl + [DllImport(Import.librdk, CallingConvention = CallingConvention.Cdecl)] + internal static extern void Rdk_CRdkCmnPostEffectExecutionControl_SetCallbacks( + Rhino.RDK.Delegates.POST_EFFECT_EXECUTION_CONTROL_PROC__DELETE_THIS delete, + Rhino.RDK.Delegates.POST_EFFECT_EXECUTION_CONTROL_PROC__READY_TO_EXECUTE ready_to_execute + ); + //CmnTask [DllImport(Import.librdk, CallingConvention = CallingConvention.Cdecl)] internal static extern void Rdk_Task_SetCallbacks( @@ -1452,7 +1462,8 @@ internal static extern void RhCmnObjectManagerNodeProperty_SetCallbacks( Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyDisplayNameDelegate delegateDisplayName, Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyParameterNameDelegate delegateParameterName, Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyImageDelegate delegateImage, - Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyEditableDelegate delegateEditable + Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyEditableDelegate delegateEditable, + Rhino.ObjectManager.ObjectManagerNodeQuickAccessProperty.NodePropertyTypeDelegate delegateParameterType ); [DllImport(Import.lib, CallingConvention = CallingConvention.Cdecl)] @@ -1468,7 +1479,8 @@ internal static extern void RhCmnObjectManagerNodeCommand_SetCallbacks( Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandIsDefaultDelegate delegateIsDefault, Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandIsEnabledDelegate delegateIsEnabled, Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandIsRadioButtonDelegate delegateIsRadioButton, - Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandSupportsMultipleSelectionDelegate delegateMultipleSupport + Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandSupportsMultipleSelectionDelegate delegateMultipleSupport, + Rhino.ObjectManager.ObjectManagerNodeCommand.NodeCommandMenuOrderDelegate delegateMenuOrder ); internal delegate void ConstraintAddRemProc(uint docSerial, IntPtr Constraints, IntPtr Constraint); diff --git a/src/dotnet/opennurbs/opennurbs_3dm_settings.cs b/src/dotnet/opennurbs/opennurbs_3dm_settings.cs index 57dd94f1d..438b594bf 100644 --- a/src/dotnet/opennurbs/opennurbs_3dm_settings.cs +++ b/src/dotnet/opennurbs/opennurbs_3dm_settings.cs @@ -9,6 +9,67 @@ // functionality is merged into other wrapper classes namespace Rhino.DocObjects { + /// + /// Default grid settings for a document + /// + public class ConstructionPlaneGridDefaults + { + internal static ConstructionPlaneGridDefaults FromConstPointer(IntPtr ptrConstructionPlaneDefaults) + { + ConstructionPlaneGridDefaults defaults = new ConstructionPlaneGridDefaults(); + double gridSpacing = defaults.GridSpacing; + double snapSpacing = defaults.SnapSpacing; + int gridLineCount = defaults.GridLineCount; + int gridThickFrequency = defaults.GridThickFrequency; + bool showGrid = defaults.ShowGrid; + bool showGridAxes = defaults.ShowGridAxes; + bool showWorldAxes = defaults.ShowWorldAxes; + UnsafeNativeMethods.ON_3dmConstructionPlaneGridDefaults_Get(ptrConstructionPlaneDefaults, ref gridSpacing, ref snapSpacing, ref gridLineCount, + ref gridThickFrequency, ref showGrid, ref showGridAxes, ref showWorldAxes); + defaults.GridSpacing = gridSpacing; + defaults.SnapSpacing = snapSpacing; + defaults.GridLineCount = gridLineCount; + defaults.GridThickFrequency = gridThickFrequency; + defaults.ShowGrid = showGrid; + defaults.ShowGridAxes = showGridAxes; + defaults.ShowWorldAxes = showWorldAxes; + return defaults; + } + + internal void SetupNativePointer(IntPtr ptrConstructionPlaneDefaults) + { + UnsafeNativeMethods.ON_3dmConstructionPlaneGridDefaults_Set(ptrConstructionPlaneDefaults, GridSpacing, SnapSpacing, GridLineCount, + GridThickFrequency, ShowGrid, ShowGridAxes, ShowWorldAxes); + } + + /// Distance between grid lines + public double GridSpacing { get; set; } = 1.0; + + /// + /// When grid snap is enabled, the distance between snap points. Typically + /// this is the same distance as grid spacing + /// + public double SnapSpacing { get; set; } = 1.0; + + /// Number of grid lines in each direction + public int GridLineCount { get; set; } = 70; + + /// + /// This line frequency. 0: none, 1: all lines are thick, 2: every other is + /// thick, ... + /// + public int GridThickFrequency { get; set; } = 5; + + /// Show the grid + public bool ShowGrid { get; set; } = true; + + /// Show the grid axes + public bool ShowGridAxes { get; set; } = true; + + /// Show the world axes icon in the corner + public bool ShowWorldAxes { get; set; } = true; + } + // Can't add a cref to an XML comment here since the NamedConstructionPlaneTable // is not included in the OpenNURBS flavor build of RhinoCommon @@ -307,6 +368,7 @@ public class ViewInfo : IDisposable // ON_3dmView /// /// Create a default ViewInfo instance /// + /// 8.2 public ViewInfo() { m_parent = null; @@ -1155,6 +1217,7 @@ private Vector3d PerpVectOnXYPlane(Vector3d vec) /// This is used in conjunction with the class. /// /// 5.0 + /// 8.6 [EditorBrowsable(EditorBrowsableState.Never), Obsolete("Please use EarthCoordinateSystem")] public enum BasepointZero { diff --git a/src/dotnet/opennurbs/opennurbs_archive.cs b/src/dotnet/opennurbs/opennurbs_archive.cs index e70fc6b46..5e11d51c5 100644 --- a/src/dotnet/opennurbs/opennurbs_archive.cs +++ b/src/dotnet/opennurbs/opennurbs_archive.cs @@ -4537,12 +4537,14 @@ public SerializationOptions() /// /// Gets or sets a value indicating whether to write render meshes /// + /// 8.4 public bool WriteRenderMeshes { get; set; } /// /// Gets or sets a value indicating whether to write analysis meshes /// + /// 8.4 public bool WriteAnalysisMeshes { get; set; } } } diff --git a/src/dotnet/opennurbs/opennurbs_beam.cs b/src/dotnet/opennurbs/opennurbs_beam.cs index 595268aef..ae29bbb25 100644 --- a/src/dotnet/opennurbs/opennurbs_beam.cs +++ b/src/dotnet/opennurbs/opennurbs_beam.cs @@ -182,6 +182,7 @@ public Brep ToBrep(bool splitKinkyFaces) /// /// The extrusion component index. /// The Brep component index if successful. Otherwise, is returned. + /// 8.1 public ComponentIndex GetBrepFormComponentIndex(ComponentIndex extrusionComponentIndex) { IntPtr ptr_const_this = ConstPointer(); @@ -607,6 +608,7 @@ public Mesh GetMesh(MeshType meshType) /// The mesh. /// The mesh type. /// True on success. + /// 8.3 public bool SetMesh(Mesh mesh, MeshType meshType) { if (null == mesh ) return false; diff --git a/src/dotnet/opennurbs/opennurbs_bezier.cs b/src/dotnet/opennurbs/opennurbs_bezier.cs index 05e935d74..7c64ff060 100644 --- a/src/dotnet/opennurbs/opennurbs_bezier.cs +++ b/src/dotnet/opennurbs/opennurbs_bezier.cs @@ -451,6 +451,9 @@ public static BezierCurve[] CreateCubicBeziers(Curve sourceCurve, double distanc /// 6.0 public static BezierCurve[] CreateBeziers(Curve sourceCurve) { + if (sourceCurve == null) + return new BezierCurve[0]; + IntPtr const_ptr_source = sourceCurve.ConstPointer(); IntPtr ptr_bez_array = UnsafeNativeMethods.ON_SimpleArray_BezierCurveNew(); int count = UnsafeNativeMethods.RHC_RhinoMakeBeziers(const_ptr_source, ptr_bez_array); diff --git a/src/dotnet/opennurbs/opennurbs_brep.cs b/src/dotnet/opennurbs/opennurbs_brep.cs index 08a744356..d75218aeb 100644 --- a/src/dotnet/opennurbs/opennurbs_brep.cs +++ b/src/dotnet/opennurbs/opennurbs_brep.cs @@ -126,6 +126,7 @@ public class BrepEdgeFilletDistance /// /// The parameter along the edge where to apply the fillet distance /// The distance to apply + /// 8.7 public BrepEdgeFilletDistance(double edgeParameter, double filletDistance) { EdgeParameter = edgeParameter; @@ -135,11 +136,13 @@ public BrepEdgeFilletDistance(double edgeParameter, double filletDistance) /// /// The parameter along the BrepEdge where to apply a fillet distance (radius) /// + /// 8.7 public double EdgeParameter { get; } /// /// Distance to fillet /// + /// 8.7 public double FilletDistance { get; } } @@ -473,6 +476,56 @@ public static Brep[] CutUpSurface(Surface surface, IEnumerable curves, bo } } + /// + /// Extends Faces to meet and trims the faces to each other. If input faces intersect without extending, the selection point indicates the side to keep + /// + /// [in] first face to connect + /// selection point on first face near the edge to extend. + /// [in] second surface + /// selection point on second face near the edge to extend. + /// [in] tolerance used for intersecting faces and simplifing extension curve + /// [in] angle tolerance in radians used for simplifying extendsion curve + /// [out] first face extended and trimmed to connect with the second face + /// [out] second face extended and trimmed to connect with the first face + /// true if valid connection found + public static bool ExtendBrepFacesToConnect(BrepFace Face0, Point3d f0_sel_pt, BrepFace Face1, Point3d f1_sel_pt, double tol, double angleTol, out Brep outBrep0, out Brep outBrep1) + { + IntPtr pFace0 = Face0.ConstPointer(); + IntPtr pFace1 = Face1.ConstPointer(); + IntPtr pOutBrep0 = IntPtr.Zero; + IntPtr pOutBrep1 = IntPtr.Zero; + + bool rc = UnsafeNativeMethods.RHC_RhinoExtendBrepFacesToConnect1(pFace0, f0_sel_pt, pFace1, f1_sel_pt, tol, angleTol, ref pOutBrep0, ref pOutBrep1); + outBrep0 = IntPtr.Zero == pOutBrep0 ? null : new Brep(pOutBrep0, null); + outBrep1 = IntPtr.Zero == pOutBrep1 ? null : new Brep(pOutBrep1, null); + return rc; + } + + /// + /// Extends Faces to meet and trims the faces to each other. If input faces intersect without extending, the selection point indicates the side to keep + /// + /// [in] first face to connect + /// [in] edge to extend. + /// [in] second surface + /// [in] edge to extend. + /// [in] tolerance used for intersecting faces and simplifing extension curve + /// [in] angle tolerance in radians used for simplifying extendsion curve + /// [out] first face extended and trimmed to connect with the second face + /// [out] second face extended and trimmed to connect with the first face + /// true if valid connection found + public static bool ExtendBrepFacesToConnect(BrepFace Face0, int edgeIndex0, BrepFace Face1, int edgeIndex1, double tol, double angleTol, out Brep outBrep0, out Brep outBrep1) + { + IntPtr pFace0 = Face0.ConstPointer(); + IntPtr pFace1 = Face1.ConstPointer(); + IntPtr pOutBrep0 = IntPtr.Zero; + IntPtr pOutBrep1 = IntPtr.Zero; + + bool rc = UnsafeNativeMethods.RHC_RhinoExtendBrepFacesToConnect2(pFace0, edgeIndex0, pFace1, edgeIndex1, tol, angleTol, ref pOutBrep0, ref pOutBrep1); + outBrep0 = IntPtr.Zero == pOutBrep0 ? null : new Brep(pOutBrep0, null); + outBrep1 = IntPtr.Zero == pOutBrep1 ? null : new Brep(pOutBrep1, null); + return rc; + } + #endif /// @@ -2026,28 +2079,8 @@ public static Brep[] CreateChamferSurface(BrepFace face0, Point2d uv0, double ra /// 6.0 public static Brep[] CreateFilletEdges(Brep brep, IEnumerable edgeIndices, IEnumerable startRadii, IEnumerable endRadii, BlendType blendType, RailType railType, double tolerance) { - if (brep == null) throw new ArgumentNullException(nameof(brep)); - - var ptr_const_brep = brep.ConstPointer(); - - using (var edges = new SimpleArrayInt(edgeIndices)) - using (var radii0 = new SimpleArrayDouble(startRadii)) - using (var radii1 = new SimpleArrayDouble(endRadii)) - using (var out_breps = new SimpleArrayBrepPointer()) - { - var ptr_const_edges = edges.ConstPointer(); - var ptr_const_radii0 = radii0.ConstPointer(); - var ptr_const_radii1 = radii1.ConstPointer(); - - var ptr_out_breps = out_breps.NonConstPointer(); - - var rc = UnsafeNativeMethods.RHC_RhinoFilletEdges(ptr_const_brep, ptr_const_edges, ptr_const_radii0, ptr_const_radii1, (int)blendType, (int)railType, tolerance, ptr_out_breps); - if (rc) - return out_breps.ToNonConstArray(); - - GC.KeepAlive(brep); - return new Brep[0]; - } + // use ON_DEFAULT_ANGLE_TOLERANCE for the angle tolerance + return CreateFilletEdges(brep, edgeIndices, startRadii, endRadii, blendType, railType, blendType == BlendType.Blend, tolerance, Math.PI/180); } /// @@ -2061,7 +2094,7 @@ public static Brep[] CreateFilletEdges(Brep brep, IEnumerable edgeIndices, /// The rail type. /// UJse setback fillets (only used with blendType=) /// The tolerance to be used to perform calculations. - /// Angle tolerance to be used to perform calculations. + /// Angle tolerance to be used to perform calculations [radians]. /// Array of Breps if successful. /// 8.6 public static Brep[] CreateFilletEdges(Brep brep, IEnumerable edgeIndices, IEnumerable startRadii, IEnumerable endRadii, BlendType blendType, RailType railType, bool setbackFillets, double tolerance, double angleTolerance) @@ -2100,7 +2133,7 @@ public static Brep[] CreateFilletEdges(Brep brep, IEnumerable edgeIndices, /// The rail type. /// UJse setback fillets (only used with blendType=) /// The tolerance to be used to perform calculations. - /// Angle tolerance to be used to perform calculations. + /// Angle tolerance to be used to perform calculations [radians]. /// Array of Breps if successful. /// 8.6 public static Brep[] CreateFilletEdgesVariableRadius(Brep brep, IEnumerable edgeIndices, IDictionary> edgeDistances, BlendType blendType, RailType railType, bool setbackFillets, double tolerance, double angleTolerance) @@ -2815,6 +2848,55 @@ public static Brep[] CreateBooleanDifference(Brep firstBrep, Brep secondBrep, do return BooleanIntDiffHelper(new[] { firstBrep }, new[] { secondBrep }, tolerance, false, manifoldOnly); } + /// + /// Compute the solid difference between two sets of Breps. + /// + /// The set to be differenced from. + /// The set to difference with. + /// Tolerance to use for the boolean operation. + /// If true, non-manifold input breps are ignored. + /// results[i] is the result if subtracting something from firstSet[indexMap[i]]. + /// An array of Brep results or null on failure. May be empty if all of the firstSet is differenced away. + /// 8.13 + public static Brep[] CreateBooleanDifferenceWithIndexMap(IEnumerable firstSet, IEnumerable secondSet, double tolerance, bool manifoldOnly, out int[] indexMap) + { + if (firstSet == null) { throw new ArgumentNullException(nameof(firstSet)); } + if (secondSet == null) { throw new ArgumentNullException(nameof(secondSet)); } + + using (var input_set1 = new SimpleArrayBrepPointer()) + using (var input_set2 = new SimpleArrayBrepPointer()) + using (var output = new SimpleArrayBrepPointer()) + using (var index_map = new SimpleArrayInt()) + { + foreach (var brep in firstSet) + { + input_set1.Add(brep, true); + } + + foreach (var brep in secondSet) + { + input_set2.Add(brep, true); + } + + IntPtr const_ptr_inputset1 = input_set1.ConstPointer(); + IntPtr const_ptr_inputset2 = input_set2.ConstPointer(); + IntPtr ptr_output = output.NonConstPointer(); + IntPtr ptr_index_map = index_map.NonConstPointer(); + + if(UnsafeNativeMethods.RHC_RhinoBooleanDifference(const_ptr_inputset1, const_ptr_inputset2, ptr_output, ptr_index_map, tolerance, manifoldOnly)) + { + indexMap = index_map.ToArray(); + return output.ToNonConstArray(); + } + + GC.KeepAlive(firstSet); + GC.KeepAlive(secondSet); + + indexMap = null; + return null; + } + } + /// /// Splits shared areas of Breps and creates separate Breps from the shared and unshared parts. /// @@ -4369,6 +4451,7 @@ public double GetVolume(double relativeTolerance, double absoluteTolerance) /// The fitting tolerance for the offset. When in doubt, use the document's absolute tolerance. /// The angle tolerance in radians for identifying creases when creasing corners. When in doubt, use the document's angle tolerance. /// The brep with inset faces on success. Null on error. + /// 8.8 [ConstOperation] public Brep InsetFaces(IEnumerable faceIndices, double distance, bool loose, bool ignoreSeams, bool creaseCorners, double tolerance, double angleTolerance) { @@ -4598,6 +4681,33 @@ public bool Repair(double tolerance) return UnsafeNativeMethods.ON_Brep_Repair(ptr_brep, tolerance); } + /// + /// Splits, or cuts up, a surface. Designed to split the underlying surface of a Brep face with edge curves. + /// + /// The surface to cut up. + /// + /// The edge curves with consistent orientation. + /// The curves should lie on the surface. + /// If true, the input curves are oriented clockwise. + /// The fitting tolerance. + /// Used to decide which face to keep. For best results, should be at least 2 * fitTolerance. + /// The Brep pieces if successful, an empty array on failure. + /// 8.12 + public static Brep[] CutUpSurface(Surface surface, IEnumerable curves, bool flip, double fitTolerance, double keepTolerance) + { + using (var curveArray = new SimpleArrayCurvePointer(curves)) + using (var brepArray = new SimpleArrayBrepPointer()) + { + IntPtr ptr_const_surface = surface.ConstPointer(); + IntPtr ptr_const_curves = curveArray.ConstPointer(); + IntPtr ptr_breps = brepArray.NonConstPointer(); + UnsafeNativeMethods.RHC_RhinoCutUpSurface(ptr_const_surface, ptr_const_curves, flip, fitTolerance, keepTolerance, ptr_breps); + GC.KeepAlive(surface); + GC.KeepAlive(curves); + return brepArray.ToNonConstArray(); + } + } + /// /// Remove all inner loops, or holes, in a Brep. /// diff --git a/src/dotnet/opennurbs/opennurbs_curve.cs b/src/dotnet/opennurbs/opennurbs_curve.cs index 8c9a11642..47eaa80de 100644 --- a/src/dotnet/opennurbs/opennurbs_curve.cs +++ b/src/dotnet/opennurbs/opennurbs_curve.cs @@ -7,6 +7,7 @@ using Rhino.Runtime; using Rhino.Display; + namespace Rhino.Geometry { /// @@ -813,6 +814,47 @@ public static Curve CreateFilletCornersCurve(Curve curve, double radius, double return GeometryBase.CreateGeometryHelper(ptr, null) as Curve; } + private static Curve BuildRoundedCornerRectangle(Rectangle3d rectangle, bool arcMode, double value) + { + if (!rectangle.IsValid) + return null; + + Point3d[] points = new Point3d[] + { + rectangle.Corner(0), + rectangle.Corner(1), + rectangle.Corner(2), + rectangle.Corner(3) + }; + + IntPtr ptr = UnsafeNativeMethods.RHC_RhBuildRoundedCornerRectangle(4, points, arcMode, value); + return GeometryBase.CreateGeometryHelper(ptr, null) as Curve; + } + + /// + /// Creates an arc-cornered (rounded) rectangular curve. + /// + /// The rectangle. + /// The arc radius at each corner. + /// Aa arc-cornered rectangular curve if successful, null otherwise. + /// 8.9 + public static Curve CreateArcCornerRectangle(Rectangle3d rectangle, double radius) + { + return BuildRoundedCornerRectangle(rectangle, true, radius); + } + + /// + /// Creates a conic-corned (rounded) rectangular curve. + /// + /// The rectangle. + /// The rho value at each corner, in the exclusive range (0.0, 1.0). + /// A conic-cornered rectangular curve if successful, null otherwise. + /// 8.9 + public static Curve CreateConicCornerRectangle(Rectangle3d rectangle, double rho) + { + return BuildRoundedCornerRectangle(rectangle, false, rho); + } + #endif //RHINO_SDK /// @@ -919,6 +961,53 @@ public static Curve[] JoinCurves(IEnumerable inputCurves, double joinTole } } + /// + /// Joins a collection of curve segments together. + /// + /// An array, a list or any enumerable set of curve segments to join. + /// Joining tolerance, + /// i.e. the distance between segment end-points that is allowed. + /// + /// If true, curve endpoints will be compared to curve start points. + /// If false, all start and endpoints will be compared and copies of input curves may be reversed in output. + /// + /// inputCurves[i] is part of returnValue[key[i]] + /// Set true to use the simple joining method. In general, set this parameter to false. + /// An array of joined curves. This array can be empty. + /// If inputCurves is null. + /// 8.12 + public static Curve[] JoinCurves(IEnumerable inputCurves, double joinTolerance, bool preserveDirection, bool simpleJoin, out int[] key) + { + if (null == inputCurves) + throw new ArgumentNullException("inputCurves"); + + using (SimpleArrayCurvePointer input = new SimpleArrayCurvePointer(inputCurves)) + using (SimpleArrayCurvePointer output = new SimpleArrayCurvePointer()) + using (SimpleArrayInt indexMap = new SimpleArrayInt()) + { + IntPtr inputPtr = input.ConstPointer(); + IntPtr outputPtr = output.NonConstPointer(); + + //2-Jan-2024 Joshua Kennedy https://mcneel.myjetbrains.com/youtrack/issue/RH-79377/Index-tracking-in-Curve-Join. + IntPtr indexMapPtr = indexMap.NonConstPointer(); + + // 18-Jan-2021 Dale Fugier, https://mcneel.myjetbrains.com/youtrack/issue/RH-67058 + // 24-Sep-2024 Dale Fugier, https://mcneel.myjetbrains.com/youtrack/issue/RH-83945 +#if RHINO_SDK + bool rc = simpleJoin + ? UnsafeNativeMethods.RHC_RhinoJoinCurves(inputPtr, outputPtr, joinTolerance, preserveDirection, indexMapPtr) + : UnsafeNativeMethods.RHC_RhinoMergeCurves(inputPtr, outputPtr, joinTolerance, preserveDirection, indexMapPtr); +#else + bool rc = UnsafeNativeMethods.ONC_JoinCurves(inputPtr, outputPtr, joinTolerance, preserveDirection, indexMapPtr); +#endif + + GC.KeepAlive(inputCurves); + key = indexMap.ToArray(); + return rc ? output.ToNonConstArray() : new Curve[0]; + } + } + + /// /// Joins a collection of curve segments together. /// @@ -2124,6 +2213,18 @@ internal override GeometryBase DuplicateShallowHelper() #if RHINO_SDK + /// + /// Repairs a curve. + /// + /// The repair tolerance. + /// true if successful, false otherwise. + /// 8.12 + public bool Repair(double tolerance) + { + IntPtr ptr_this = NonConstPointer(); + return UnsafeNativeMethods.RHC_RhinoRepairCurve(ptr_this, tolerance); + } + /// /// Local minimization for point on a curve with tangent perpendicular to N. /// @@ -2199,7 +2300,13 @@ public Curve[] GetSubCurves() /// /// Smooths a curve by averaging the positions of control points in a specified region. /// - /// The smoothing factor, which controls how much control points move towards the average of the neighboring control points. + /// + /// The smoothing factor, which controls how much control + /// points move towards the average of the neighboring control points. + /// Note that this smoothFactor is equivalent to twice the smooth factor used in + /// the Smooth command: on a polyline, Rhino _Smooth with a factor of 0.2 is the + /// same as with a factor of 0.4. + /// /// When true control points move in X axis direction. /// When true control points move in Y axis direction. /// When true control points move in Z axis direction. @@ -2215,7 +2322,13 @@ public Curve Smooth(double smoothFactor, bool bXSmooth, bool bYSmooth, bool bZSm /// /// Smooths a curve by averaging the positions of control points in a specified region. /// - /// The smoothing factor, which controls how much control points move towards the average of the neighboring control points. + /// + /// The smoothing factor, which controls how much control + /// points move towards the average of the neighboring control points. + /// Note that this smoothFactor is equivalent to twice the smooth factor used in + /// the Smooth command: on a polyline, Rhino _Smooth with a factor of 0.2 is the + /// same as with a factor of 0.4. + /// /// When true control points move in X axis direction. /// When true control points move in Y axis direction. /// When true control points move in Z axis direction. @@ -5646,6 +5759,24 @@ public Curve RibbonOffset(double distance, double blendRadius, Point3d direction return GeometryBase.CreateGeometryHelper(ptr, null) as Curve; } + /// + /// Ribbon offset method to mimic RibbonOffset command + /// + /// The ribbon offset parameters + /// on success an array of split curves representing the sweep rail segments, null on failure + /// on success an array of cross section curves used during brep creation, null on failure + /// on success and array of breps representing the ribbon surfaces, null on failure + /// return an offset curve on success, null on failure + public Curve RibbonOffset(RibbonOffsetParameters ribbonParameters, out Curve[] railCurves, out Curve[] crossSectionCurves, out Brep[] brepSurfaces) + { + var input_curve = this.DuplicateCurve(); + //Generate ribbon surfaces and curves + var offset_curve = RibbonOffsets.RibbonOffsetSurfacing.CreateRibbonOffset(input_curve,ribbonParameters, out railCurves, out crossSectionCurves, out brepSurfaces); + + input_curve?.Dispose(); + return offset_curve; + } + /// /// Offset this curve on a brep face surface. This curve must lie on the surface. /// @@ -6007,10 +6138,123 @@ public Curve OffsetTangentToSurface(Surface surface, double height) return GeometryBase.CreateGeometryHelper(pOffsetCurve, null) as Curve; } + /// + /// Gets the curve's control polygon. + /// + /// The control polygon as a polyline if successful, null otherwise. + /// 8.11 + [ConstOperation] + public Polyline ControlPolygon() + { + IntPtr ptr_const_this = ConstPointer(); + using (var points = new SimpleArrayPoint3d()) + { + IntPtr ptr_points = points.NonConstPointer(); + bool rc = UnsafeNativeMethods.RHC_RhExtractCurveControlPolygon(ptr_const_this, ptr_points); + if (rc) + return new Geometry.Polyline(points.ToArray()); + return null; + } + } #endif + /// + /// + /// + /// + public double[] SpanVector() + { + double[] vector = null; + using (SimpleArrayDouble output = new SimpleArrayDouble()) + { + IntPtr outputPtr = output.NonConstPointer(); + UnsafeNativeMethods.ONC_SpanVector(this.ConstPointer(), outputPtr); + vector = output.ToArray(); + } + return vector; + } #endregion methods } + + /// + /// Advanced parameters for RibbonOffset + /// Parameters mimic the RibbonOffset Command. + /// + public class RibbonOffsetParameters + { + /// + /// Offset curve distance from input curve. + /// + public double OffsetDistance { get; set; } = 0; + + /// + /// Inside or Outside point location + /// + public Point3d OffsetLocation { get; set; } + + /// + /// Used to determine self-intersections of offset curve, not offset error. + /// + public double OffsetTolerance { get; set; } + /// + /// A vector that indicates the normal of the plane in which the offset will occur. + /// This vector is typically similar to a logical extrude direction for the closed input curve. + /// + public Vector3d OffsetPlaneVector3d { get; set; } = Vector3d.Unset; + + /// + /// Positive, typically the same as distance. When the offset results in a self-intersection + /// that gets trimmed off at a kink, the kink will be blended out using this radius. + /// + public double BlendRadius { get; set; } + + /// + /// Rebuild offset curve with defined number of control points + /// 0 for disabled + /// + public int RebuildPointCount { get; set; } = 0; + + /// + /// Refit the offset curve to a specified tolerance + /// 0 for disabled + /// + public double RefitTolerance { get; set; } = 0; + + /// + /// When false: cross section slashes between input and output curve are located at the ends of ruled spans. + /// When true: cross section slashes between input and output curve are located at the mid points of ruled spans and blends. + /// + public bool AlignCrossSections { get; set; } + + /// + /// 0 - no surfaces will be created, curves only + /// 1 - Simple Sweep 2 + /// 2 - Sweep 2 mixed with NetworkSrf corners + /// + public RibbonOffsetSurfaceMethod RibbonSurfaceGenerationMethod { get; set; } = RibbonOffsetSurfaceMethod.None; + } + + /// + /// Enum for RibbonOffset surface generation + /// + public enum RibbonOffsetSurfaceMethod : int + { + /// + /// No Surfaces will be created + /// + None = 0, + + /// + /// Creates surfaces based off of Sweep 2 Rails + /// + Sweep2 = 1, + + /// + /// Creates a mix of sweeps and network surfaces. + /// NetworkSrf will be applied in corners with 3 sides + /// + Sweep2NetworkSrf = 2, + } } diff --git a/src/dotnet/opennurbs/opennurbs_defines.cs b/src/dotnet/opennurbs/opennurbs_defines.cs index 29117b718..4bc29948d 100644 --- a/src/dotnet/opennurbs/opennurbs_defines.cs +++ b/src/dotnet/opennurbs/opennurbs_defines.cs @@ -1,6 +1,7 @@ using System; using System.Runtime.InteropServices; using System.Collections.Generic; +using Rhino.Geometry; namespace Rhino { @@ -669,6 +670,211 @@ out Rhino.Geometry.Vector3d nt nt = Rhino.Geometry.Vector3d.Unset; return UnsafeNativeMethods.ONC_EvNormalPartials(ds, dt, dss, dst, dtt, ref ns, ref nt); } + + #region Integration +#if false // moving into rhino 9 for now + + /// + /// + /// + /// + /// + /// + /// + public delegate double Integrate1Callback(Object context, Rhino.Geometry.CurveEvaluationSide side, double t); + + /// + /// + /// + /// + /// + /// + /// + /// + public delegate double Integrate2Callback(Object context, Rhino.Geometry.CurveEvaluationSide side, double s, double t); + + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate double Integrate1CallbackWrapperDelegate(IntPtr gchContextWrapper, int limitDirection, double t); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + private delegate double Integrate2CallbackWrapperDelegate(IntPtr gchContextWrapper, int limitDirection, double s, double t); + + private class Context1Wrapper + { + public Integrate1Callback func; + public Object context; + + public Context1Wrapper(Integrate1Callback _func, Object _context) + { + func = _func; + context = _context; + } + } + private class Context2Wrapper + { + public Integrate2Callback func; + public Object context; + + public Context2Wrapper(Integrate2Callback _func, Object _context) + { + func = _func; + context = _context; + } + } + private static double Integrate1CallbackWrapper(IntPtr ptrContextWrapper, int limitDirection, double t) + { + Context1Wrapper contextWrapper = (GCHandle.FromIntPtr(ptrContextWrapper).Target) as Context1Wrapper; + if (null == contextWrapper) return double.NaN; + if (null == contextWrapper.context || null == contextWrapper.func) return double.NaN; + + // use the side enum + Rhino.Geometry.CurveEvaluationSide side; + if (limitDirection == 0) side = CurveEvaluationSide.Default; + else if (limitDirection < 0) side = CurveEvaluationSide.Below; + else side = CurveEvaluationSide.Above; + + return contextWrapper.func(contextWrapper.context, side, t); + } + + private static double Integrate2CallbackWrapper(IntPtr ptrContextWrapper, int limitDirection, double s, double t) + { + Context2Wrapper contextWrapper = (GCHandle.FromIntPtr(ptrContextWrapper).Target) as Context2Wrapper; + if (null == contextWrapper) return double.NaN; + if (null == contextWrapper.context || null == contextWrapper.func) return double.NaN; + + Rhino.Geometry.CurveEvaluationSide side; + if (limitDirection == 0) side = CurveEvaluationSide.Default; + else if (limitDirection < 0) side = CurveEvaluationSide.Below; + else side = CurveEvaluationSide.Above; + return contextWrapper.func(contextWrapper.context, side, s, t); + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static double Integrate(Integrate1Callback func, object context, Interval limits, double relativeTolerance, double absoluteTolerance, ref double errorBound) + { + if (null != func && null != context) + { + Integrate1CallbackWrapperDelegate funcWrapper = new Integrate1CallbackWrapperDelegate(Integrate1CallbackWrapper); + Context1Wrapper contextWrapper = new Context1Wrapper(func, context); + + var gchCallbackWrapper = GCHandle.Alloc(funcWrapper); + IntPtr ptrCallbackWrapper = Marshal.GetFunctionPointerForDelegate(funcWrapper); + var gchContextWrapper = GCHandle.Alloc(contextWrapper); + IntPtr ptrContextWrapper = GCHandle.ToIntPtr(gchContextWrapper); + double rc = UnsafeNativeMethods.ON_Integrate_1D(ptrCallbackWrapper, ptrContextWrapper, limits, relativeTolerance, absoluteTolerance, ref errorBound); + + gchContextWrapper.Free(); + gchCallbackWrapper.Free(); + + return rc; + } + return 0.0; + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static double Integrate(Integrate1Callback func, object context, Curve curve, double relativeTolerance, double absoluteTolerance, ref double errorBound) + { + if (null != func && null != context && null != curve) + { + Integrate1CallbackWrapperDelegate funcWrapper = new Integrate1CallbackWrapperDelegate(Integrate1CallbackWrapper); + Context1Wrapper contextWrapper = new Context1Wrapper(func, context); + + var gchCallbackWrapper = GCHandle.Alloc(funcWrapper); + IntPtr ptrCallbackWrapper = Marshal.GetFunctionPointerForDelegate(funcWrapper); + var gchContextWrapper = GCHandle.Alloc(contextWrapper); + IntPtr ptrContextWrapper = GCHandle.ToIntPtr(gchContextWrapper); + double rc = UnsafeNativeMethods.ON_Integrate_1D_Curve(ptrCallbackWrapper, ptrContextWrapper, curve.ConstPointer(), relativeTolerance, absoluteTolerance, ref errorBound); + + gchContextWrapper.Free(); + gchCallbackWrapper.Free(); + + return rc; + } + return 0.0; + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static double Integrate(Integrate2Callback func, object context, Interval limits1, Interval limits2, double relativeTolerance, double absoluteTolerance, ref double errorBound) + { + if (null != func && null != context) + { + Integrate2CallbackWrapperDelegate funcWrapper = new Integrate2CallbackWrapperDelegate(Integrate2CallbackWrapper); + Context2Wrapper contextWrapper = new Context2Wrapper(func, context); + + var gchCallbackWrapper = GCHandle.Alloc(funcWrapper); + IntPtr ptrCallbackWrapper = Marshal.GetFunctionPointerForDelegate(funcWrapper); + var gchContextWrapper = GCHandle.Alloc(contextWrapper); + IntPtr ptrContextWrapper = GCHandle.ToIntPtr(gchContextWrapper); + double rc = UnsafeNativeMethods.ON_Integrate_2D(ptrCallbackWrapper, ptrContextWrapper, limits1, limits2, relativeTolerance, absoluteTolerance, ref errorBound); + + gchContextWrapper.Free(); + gchCallbackWrapper.Free(); + + return rc; + } + return 0.0; + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static double Integrate(Integrate2Callback callback, object context, Surface surface, double relativeTolerance, double absoluteTolerance, ref double errorBound) + { + if (null != callback && null != context && null != surface) + { + Integrate2CallbackWrapperDelegate funcWrapper = new Integrate2CallbackWrapperDelegate(Integrate2CallbackWrapper); + Context2Wrapper contextWrapper = new Context2Wrapper(callback, context); + + var gchCallbackWrapper = GCHandle.Alloc(funcWrapper); + IntPtr ptrCallbackWrapper = Marshal.GetFunctionPointerForDelegate(funcWrapper); + var gchContextWrapper = GCHandle.Alloc(contextWrapper); + IntPtr ptrContextWrapper = GCHandle.ToIntPtr(gchContextWrapper); + double rc = UnsafeNativeMethods.ON_Integrate_1D_Curve(ptrCallbackWrapper, ptrContextWrapper, surface.ConstPointer(), relativeTolerance, absoluteTolerance, ref errorBound); + + gchContextWrapper.Free(); + gchCallbackWrapper.Free(); + + return rc; + } + return 0.0; + } + #endif + #endregion // Integration } diff --git a/src/dotnet/opennurbs/opennurbs_extensions.cs b/src/dotnet/opennurbs/opennurbs_extensions.cs index 0bd475e50..b67b3587d 100644 --- a/src/dotnet/opennurbs/opennurbs_extensions.cs +++ b/src/dotnet/opennurbs/opennurbs_extensions.cs @@ -1,6 +1,7 @@ using Rhino.Collections; using Rhino.DocObjects; using Rhino.Geometry; +using Rhino.Render; using Rhino.Runtime.InteropWrappers; using System; using System.Collections; @@ -316,6 +317,7 @@ public static bool ReadRevisionHistory(string path, out string createdBy, out st /// /// A location on disk or network. /// The earth anchor point. + /// 8.3 public static EarthAnchorPoint ReadEarthAnchorPoint(string path) { EarthAnchorPoint rc = null; @@ -869,6 +871,7 @@ public int Revision /// If set, this is the model's location on the earth. This information is /// used when the model is used with GIS information. /// + /// 8.3 public EarthAnchorPoint EarthAnchorPoint { get @@ -1670,14 +1673,15 @@ public bool TryReadUserData(Guid userDataId, bool readFromAttributes, FuncThe mapping channel id to search for. /// The transformation that was applied to the mapping. /// The texture mapping if found, null otherwise. - public Rhino.Render.TextureMapping GetTextureMapping(int mappingChannelId, out Transform xform) + /// 8.9 + public TextureMapping GetTextureMapping(int mappingChannelId, out Transform xform) { IntPtr const_ptr_model = m_parent.ConstPointer(); IntPtr const_ptr_object = GetGeometryConstPointer(); Transform xformOut = new Transform(); IntPtr ptr_mapping = UnsafeNativeMethods.ON_TextureMapping_GetMappingFromONXModelObject(const_ptr_model, m_id, mappingChannelId, ref xformOut); xform = xformOut; - return ptr_mapping == IntPtr.Zero ? null : new Rhino.Render.TextureMapping(ptr_mapping); + return ptr_mapping == IntPtr.Zero ? null : new TextureMapping(ptr_mapping); } } diff --git a/src/dotnet/opennurbs/opennurbs_fpoint.cs b/src/dotnet/opennurbs/opennurbs_fpoint.cs index dfe293963..2a46f4953 100644 --- a/src/dotnet/opennurbs/opennurbs_fpoint.cs +++ b/src/dotnet/opennurbs/opennurbs_fpoint.cs @@ -869,6 +869,7 @@ public static Vector2f XAxis /// /// Gets the value of the vector with components 0,1. /// + /// 8.4 public static Vector2f YAxis { get { return new Vector2f(0f, 1f); } @@ -1047,6 +1048,7 @@ public string ToString(string format, IFormatProvider formatProvider) /// An invalid or zero length vector cannot be unitized. /// /// true on success or false on failure. + /// 8.4 public bool Unitize() { bool rc = UnsafeNativeMethods.ON_2fVector_Unitize(ref this); @@ -1060,6 +1062,7 @@ public bool Unitize() /// ///Similar to Negate, that is only provided for CLR language compliance. ///true on success or false if the vector is invalid. + /// 8.4 public bool Reverse() { bool rc = true; @@ -1076,6 +1079,7 @@ public bool Reverse() /// /// Vector to use as guide. ///true on success, false if input vector is zero or invalid. + /// 8.4 [ConstOperation] public bool PerpendicularTo(Vector2f other) { @@ -1168,6 +1172,7 @@ public bool PerpendicularTo(Vector2f other) /// A vector. /// A second vector. /// A new vector that results from the component-wise addition of the two vectors. + /// 8.4 public static Vector2f Add(Vector2f vector1, Vector2f vector2) { return new Vector2f(vector1.m_x + vector2.m_x, vector1.m_y + vector2.m_y); @@ -1201,6 +1206,7 @@ public static Vector2f Add(Vector2f vector1, Vector2f vector2) /// A vector. /// A second vector. /// A new vector that results from the component-wise difference of vector1 - vector2. + /// 8.4 public static Vector2f Subtract(Vector2f vector1, Vector2f vector2) { return new Vector2f(vector1.m_x - vector2.m_x, vector1.m_y - vector2.m_y); @@ -1213,6 +1219,7 @@ public static Vector2f Subtract(Vector2f vector1, Vector2f vector2) /// This is similar to Reverse(), but is static for CLR compliance, and with default name. /// A vector to negate. /// A new vector where all components were multiplied by -1. + /// 8.4 public static Vector2f Negate(Vector2f vector) { return new Vector2f(-vector.m_x, -vector.m_y); @@ -1225,6 +1232,7 @@ public static Vector2f Negate(Vector2f vector) /// A point. /// A vector. /// A new point that results from the addition of point and vector. + /// 8.4 public static Point2f Add(Point2f point, Vector2f vector) { return new Point2f(point.m_x + vector.m_x, point.m_y + vector.m_y); @@ -1297,6 +1305,7 @@ public float SquareLength /// This is an application of Pythagoras' theorem. /// If this vector is invalid, its length is considered 0. /// + /// 8.4 public double Length { get { return Vector2d.GetLengthHelper(m_x, m_y); } // alternatively return UnsafeNativeMethods.ON_2dVector_Length(this). Avoid the thunk to improve performance diff --git a/src/dotnet/opennurbs/opennurbs_geometry.cs b/src/dotnet/opennurbs/opennurbs_geometry.cs index b73497f56..49a15848d 100644 --- a/src/dotnet/opennurbs/opennurbs_geometry.cs +++ b/src/dotnet/opennurbs/opennurbs_geometry.cs @@ -679,42 +679,34 @@ public ComponentIndex ComponentIndex() /// string associated with key. /// true on success. /// 5.0 - public bool SetUserString(string key, string value) - { - return _SetUserString(key, value); - } + public bool SetUserString(string key, string value) => _SetUserString(key, value); + /// /// Gets user string from this geometry. /// /// id used to retrieve the string. /// string associated with the key if successful. null if no key was found. /// 5.0 - public string GetUserString(string key) - { - return _GetUserString(key); - } + public string GetUserString(string key) => _GetUserString(key); /// /// Gets the amount of user strings. /// /// 5.0 - public int UserStringCount - { - get - { - return _UserStringCount; - } - } + public int UserStringCount => _UserStringCount; /// /// Gets a copy of all (user key string, user value string) pairs attached to this geometry. /// /// A new collection. /// 5.0 - public System.Collections.Specialized.NameValueCollection GetUserStrings() - { - return _GetUserStrings(); - } + public System.Collections.Specialized.NameValueCollection GetUserStrings() => _GetUserStrings(); + + /// 8.9 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.9 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); #endregion /// diff --git a/src/dotnet/opennurbs/opennurbs_hatch.cs b/src/dotnet/opennurbs/opennurbs_hatch.cs index 60a63deb0..f446f861e 100644 --- a/src/dotnet/opennurbs/opennurbs_hatch.cs +++ b/src/dotnet/opennurbs/opennurbs_hatch.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Runtime.Serialization; using Rhino.DocObjects; using Rhino.Runtime; @@ -431,6 +432,18 @@ public void SetGradientFill(Rhino.Display.ColorGradient fill) UnsafeNativeMethods.ON_Hatch_SetGradientData(ptr_this, fill.StartPoint, fill.EndPoint, (int)fill.GradientType, fill.Repeat, ptrColorStopArray); UnsafeNativeMethods.ON_ColorStopArray_Delete(ptrColorStopArray); } + + /// + /// Constructs a Brep representation of this hatch. + /// + /// A Brep representation of this hatch if successful, null otherwise. + /// 8.9 + public Brep ToBrep() + { + IntPtr ptr_const_this = ConstPointer(); + IntPtr ptr_newbrep = UnsafeNativeMethods.ON_Geometry_BrepForm(ptr_const_this); + return IntPtr.Zero == ptr_newbrep ? null : new Brep(ptr_newbrep, null); + } } } @@ -466,7 +479,20 @@ public ColorStop(System.Drawing.Color color, double t) /// public class ColorGradient { - List _stops = new List(); + /// + /// Create a duplicate of this color gradient. + /// + /// An exact duplicate of this color gradient. + /// 8.8 + public ColorGradient Duplicate() + { + // Since ColorGradient getters always return value types or copies of its values, + // and also setters never keep a reference to an external object. + // we can implement Duplicate like a MemberwiseClone. + return (ColorGradient)MemberwiseClone(); + } + + private ColorStop[] _stops = Array.Empty(); /// /// Gradient fill type associated with this hatch @@ -485,7 +511,7 @@ public Rhino.Display.GradientType GradientType /// 7.0 public ColorStop[] GetColorStops() { - return _stops.ToArray(); + return (ColorStop[]) _stops.Clone(); } /// @@ -495,7 +521,7 @@ public ColorStop[] GetColorStops() /// 7.0 public void SetColorStops(IEnumerable stops) { - _stops = new List(stops); + _stops = stops.ToArray(); } /// diff --git a/src/dotnet/opennurbs/opennurbs_instance.cs b/src/dotnet/opennurbs/opennurbs_instance.cs index ce899b692..878079c9a 100644 --- a/src/dotnet/opennurbs/opennurbs_instance.cs +++ b/src/dotnet/opennurbs/opennurbs_instance.cs @@ -221,6 +221,44 @@ public Guid[] GetObjectIds() return ids.ToArray(); } } + + #region user strings + /// + /// Attach a user string (key,value combination) to this geometry. + /// + /// id used to retrieve this string. + /// string associated with key. + /// true on success. + /// 8.9 + public bool SetUserString(string key, string value) => _SetUserString(key, value); + + /// + /// Gets user string from this geometry. + /// + /// id used to retrieve the string. + /// string associated with the key if successful. null if no key was found. + /// 8.9 + public string GetUserString(string key) => _GetUserString(key); + + /// + /// Gets the amount of user strings. + /// + /// 8.9 + public int UserStringCount => _UserStringCount; + + /// + /// Gets a copy of all (user key string, user value string) pairs attached to this geometry. + /// + /// A new collection. + /// 8.9 + public System.Collections.Specialized.NameValueCollection GetUserStrings() => _GetUserStrings(); + + /// 8.9 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.9 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); + #endregion } /// diff --git a/src/dotnet/opennurbs/opennurbs_intersect.cs b/src/dotnet/opennurbs/opennurbs_intersect.cs index dcd4bc08e..f6bf5652d 100644 --- a/src/dotnet/opennurbs/opennurbs_intersect.cs +++ b/src/dotnet/opennurbs/opennurbs_intersect.cs @@ -505,6 +505,13 @@ public static Polyline[] MeshPlane(Mesh mesh, MeshIntersectionCache cache, IEnum if (list.Count < 1) return null; + bool reclaim_cache = false; + if (list.Count > 2 && cache == null) + { + cache = new MeshIntersectionCache(); + reclaim_cache = true; + } + IntPtr pMesh = mesh.ConstPointer(); IntPtr pCache = (null != cache) ? cache.NonConstPointer() : IntPtr.Zero; @@ -512,7 +519,13 @@ public static Polyline[] MeshPlane(Mesh mesh, MeshIntersectionCache cache, IEnum IntPtr pOutPoints = out_points.NonConstPointer(); int count = UnsafeNativeMethods.ON_Mesh_GetIntersections(pMesh, pCache, list.Count, list.m_items, tolerance, pOutPoints); - GC.KeepAlive(mesh); + GC.KeepAlive(mesh); GC.KeepAlive(cache); + + if (reclaim_cache) + { + cache.Dispose(); + } + if (count > 0) { List out_polylines = new List(out_points.Count); @@ -1059,6 +1072,22 @@ public static bool PlaneBoundingBox(Plane plane, BoundingBox boundingBox, out Po /// true on success; false on failure. /// 5.0 public static bool BrepBrep(Brep brepA, Brep brepB, double tolerance, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) + { + return BrepBrep(brepA, brepB, tolerance, true, out intersectionCurves, out intersectionPoints); + } + + /// + /// Intersects two Breps. + /// + /// First Brep for intersection. + /// Second Brep for intersection. + /// Intersection tolerance. + /// If true, join the resulting curves where possible. + /// The intersection curves will be returned here. + /// The intersection points will be returned here. + /// true on success; false on failure. + /// 8.12 + public static bool BrepBrep(Brep brepA, Brep brepB, double tolerance, bool joinCurves, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) { intersectionCurves = new Curve[0]; intersectionPoints = new Point3d[0]; @@ -1072,7 +1101,7 @@ public static bool BrepBrep(Brep brepA, Brep brepB, double tolerance, out Curve[ IntPtr brepPtrA = brepA.ConstPointer(); IntPtr brepPtrB = brepB.ConstPointer(); - bool rc = UnsafeNativeMethods.ON_Intersect_BrepBrep(brepPtrA, brepPtrB, tolerance, outputCurvesPtr, outputPointsPtr); + bool rc = UnsafeNativeMethods.ON_Intersect_BrepBrep(brepPtrA, brepPtrB, tolerance, joinCurves, outputCurvesPtr, outputPointsPtr); if (rc) { @@ -1098,6 +1127,22 @@ public static bool BrepBrep(Brep brepA, Brep brepB, double tolerance, out Curve[ /// true on success; false on failure. /// 5.0 public static bool BrepSurface(Brep brep, Surface surface, double tolerance, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) + { + return BrepSurface(brep, surface, tolerance, true, out intersectionCurves, out intersectionPoints); + } + + /// + /// Intersects a Brep and a Surface. + /// + /// A brep to be intersected. + /// A surface to be intersected. + /// A tolerance value. + /// If true, join the resulting curves where possible. + /// The intersection curves array argument. This out reference is assigned during the call. + /// The intersection points array argument. This out reference is assigned during the call. + /// true on success; false on failure. + /// 8.12 + public static bool BrepSurface(Brep brep, Surface surface, double tolerance, bool joinCurves, out Curve[] intersectionCurves, out Point3d[] intersectionPoints) { intersectionCurves = new Curve[0]; intersectionPoints = new Point3d[0]; @@ -1113,7 +1158,7 @@ public static bool BrepSurface(Brep brep, Surface surface, double tolerance, out bool rc = false; - rc = UnsafeNativeMethods.ON_Intersect_BrepSurface(brepPtr, surfacePtr, tolerance, outputCurvesPtr, outputPointsPtr); + rc = UnsafeNativeMethods.ON_Intersect_BrepSurface(brepPtr, surfacePtr, tolerance, joinCurves, outputCurvesPtr, outputPointsPtr); if (rc) { @@ -1135,40 +1180,22 @@ public static bool BrepSurface(Brep brep, Surface surface, double tolerance, out /// Second mesh for intersection. /// An array of intersection line segments, or null if no intersections were found. /// 5.0 - /// 7.0 - [Obsolete("Use the MeshMesh() method.")] public static Line[] MeshMeshFast(Mesh meshA, Mesh meshB) { - /*if (UseNewMeshIntersections) //temporarily remove new behavior - { - const double fixed_tolerance = RhinoMath.SqrtEpsilon * 10; - var arr = new[] { meshA, meshB }; - - TextLog commandline = null; - if (PrintMeshIntersectionErrors) commandline = TextLog.NewCommandLine(); + IntPtr ptrA = meshA.ConstPointer(); + IntPtr ptrB = meshB.ConstPointer(); + Line[] intersectionLines = new Line[0]; - var made_it = MeshMesh(arr, fixed_tolerance, out Polyline[] result, false, out Polyline[] _, false, out Mesh _, commandline, System.Threading.CancellationToken.None, null); - if (!made_it) return null; - if (result == null) return new Line[0]; - return result.SelectMany((pl) => pl.GetSegments()).ToArray(); - } - else*/ + using (Runtime.InteropWrappers.SimpleArrayLine arr = new Runtime.InteropWrappers.SimpleArrayLine()) { - IntPtr ptrA = meshA.ConstPointer(); - IntPtr ptrB = meshB.ConstPointer(); - Line[] intersectionLines = new Line[0]; - - using (Runtime.InteropWrappers.SimpleArrayLine arr = new Runtime.InteropWrappers.SimpleArrayLine()) - { - IntPtr pLines = arr.NonConstPointer(); - int rc = UnsafeNativeMethods.ON_Mesh_IntersectMesh(ptrA, ptrB, pLines); - if (rc > 0) - intersectionLines = arr.ToArray(); - } - Runtime.CommonObject.GcProtect(meshA, meshB); - - return intersectionLines; + IntPtr pLines = arr.NonConstPointer(); + int rc = UnsafeNativeMethods.ON_Mesh_IntersectMesh(ptrA, ptrB, pLines); + if (rc > 0) + intersectionLines = arr.ToArray(); } + Runtime.CommonObject.GcProtect(meshA, meshB); + + return intersectionLines; } /// diff --git a/src/dotnet/opennurbs/opennurbs_leader.cs b/src/dotnet/opennurbs/opennurbs_leader.cs index f3c3e8e1f..ad876e7eb 100644 --- a/src/dotnet/opennurbs/opennurbs_leader.cs +++ b/src/dotnet/opennurbs/opennurbs_leader.cs @@ -155,11 +155,12 @@ public Point3d[] Points3D { get { + var plane = Plane; var p2d = Points2D; var points3d = new Point3d[p2d.Length]; for(int i = 0; i < p2d.Length; i++) { - points3d[i] = Plane.PointAt(p2d[i].X, p2d[i].Y); + points3d[i] = plane.PointAt(p2d[i].X, p2d[i].Y); } return points3d; } diff --git a/src/dotnet/opennurbs/opennurbs_massprop.cs b/src/dotnet/opennurbs/opennurbs_massprop.cs index 019d92048..bc1a7d47b 100644 --- a/src/dotnet/opennurbs/opennurbs_massprop.cs +++ b/src/dotnet/opennurbs/opennurbs_massprop.cs @@ -1410,6 +1410,29 @@ public bool Sum(VolumeMassProperties summand) IntPtr pSum = summand.ConstPointer(); return UnsafeNativeMethods.ON_MassProperties_Sum(m_ptr, pSum); } + + /// + /// On input, this contains the mass properties for some geometry G. + /// On exit, this contains the mass properties for the transformed geometry xform(G). + /// + /// + /// The transformation. + /// When computing volumne mass properties, transform must be an affine transformation, or . + /// When computing area mass properties, transform must be a similarity transformation, or . + /// Perspective transformations are not allowed. + /// + /// + /// True if successful, false otherwise. + /// + /// + /// The Area of a transformed object can not be calculated from the area of the original object + /// if the transform is not a similarity, like a non-uniform scaling. + /// + /// 8.12 + public bool Transform(Transform xform) + { + return UnsafeNativeMethods.ON_MassProperties_Transform(m_ptr, ref xform); + } #endregion } diff --git a/src/dotnet/opennurbs/opennurbs_mesh.cs b/src/dotnet/opennurbs/opennurbs_mesh.cs index b3eba98ae..e89cd10f5 100644 --- a/src/dotnet/opennurbs/opennurbs_mesh.cs +++ b/src/dotnet/opennurbs/opennurbs_mesh.cs @@ -2365,6 +2365,7 @@ public class ShrinkWrapParameters /// Inflate mesh vertices, points and point clouds /// Mesh vertices will be inflated as though the mesh were a point cloud /// + /// 8.3 public bool InflateVerticesAndPoints { get; set; } } @@ -2915,7 +2916,7 @@ internal static Mesh CreateFromClosedPolylinesAndPoints( } IntPtr meshptr = IntPtr.Zero; - IntPtr res = UnsafeNativeMethods.RHC_Mesh2dPointsAndEdges( + IntPtr res = UnsafeNativeMethods.RHC_Mesh2dPointsAndEdges_R8SR11( points, points.Length, ip.ToArray(), @@ -3111,6 +3112,7 @@ public static Mesh CreateFromSubDControlNet(SubD subd) /// Create a mesh from a SubD control net including texture coordinates /// /// mesh representing control net on success, null on failure + /// 8.3 public static Mesh CreateFromSubDControlNetWithTextureCoordinates(SubD subd) { IntPtr constPtrSubD = subd.ConstPointer(); @@ -3615,7 +3617,7 @@ public static Mesh CreateConvexHull3D(IEnumerable points, out int[][] h using (var facetStartIndices = new Rhino.Runtime.InteropWrappers.SimpleArrayInt()) { IntPtr hfi = hullFacetIndices.NonConstPointer(); IntPtr fsi = facetStartIndices.NonConstPointer(); - IntPtr res = UnsafeNativeMethods.RHC_ConvexHull3dMesh(array, array.Length, tolerance, angleTolerance, hfi, fsi, ref errorCode); + IntPtr res = UnsafeNativeMethods.RHC_ConvexHull3dMesh_R8SR11(array, array.Length, tolerance, angleTolerance, hfi, fsi, ref errorCode); if (errorCode != 0 || res == IntPtr.Zero) return null; Mesh m = CreateGeometryHelper(res, null) as Mesh; if (m is null) return null; @@ -4204,6 +4206,7 @@ public void SetCachedTextureCoordinates(TextureMapping tm, ref Transform xf) /// /// RhinoObject that defines texture mappings /// Material with textures that define mapping channels + /// 8.7 public void SetCachedTextureCoordinatesFromMaterial(RhinoObject rhinoObject, Rhino.DocObjects.Material material) { UnsafeNativeMethods.ON_Mesh_SetCachedTextureCoordinatesFromMaterial(NonConstPointer(), rhinoObject.ConstPointer(), material.ConstPointer()); @@ -4235,6 +4238,7 @@ public CachedTextureCoordinates GetCachedTextureCoordinates(Guid textureMappingI /// RhinoObject that defines texture mappings /// Texture that defines the mapping channel /// Cached texture coordinates if available and otherwise null + /// 8.7 public CachedTextureCoordinates GetCachedTextureCoordinates(RhinoObject rhinoObject, Rhino.DocObjects.Texture texture) { var tc_pointer = UnsafeNativeMethods.ON_Mesh_GetCachedTextureCoordinates(NonConstPointer(), rhinoObject.ConstPointer(), texture.ConstPointer()); @@ -4564,6 +4568,24 @@ public void Weld(double angleToleranceRadians) UnsafeNativeMethods.RHC_RhinoWeldMesh(ptr_this, angleToleranceRadians); } + /// + /// Creates a new unwelded mesh from an existing mesh. Texture coordinates are ignored. + /// + /// The source mesh to copy. + /// The new unwelded mesh if successful, null otherwise. + /// 8.12 + public static Mesh CreateUnweldedMesh(Mesh mesh) + { + if (null == mesh) + return null; + + IntPtr ptr_const_mesh = mesh.ConstPointer(); + IntPtr ptr = UnsafeNativeMethods.RHC_CreateUnweldedMesh(ptr_const_mesh); + if (IntPtr.Zero == ptr) + return null; + return new Mesh(ptr, null); + } + /// /// Creates a single mesh face from the given input. The new mesh will be apppended to this mesh. /// @@ -6197,60 +6219,49 @@ public Task QuadRemeshAsync(IEnumerable faceBlocks, QuadRemeshParamet return Task.Run(() => QuadRemeshPrivate.QuadRemeshEngine.QuadRemeshWorker(this, faceBlocks, settings, guideCurves, progress, cancelToken), cancelToken); } - /// - /// Get the shrinkwrap plugin and pass back the shrinkwrap interface - /// - /// - private static IShrinkWrapService GetShrinkWrapPluginService() - { - Guid plugin_id = new Guid("768DD816-C492-48B4-8C1D-28665571F281"); - object obj = Rhino.RhinoApp.GetPlugInObject(plugin_id); - IShrinkWrapService sw = obj as IShrinkWrapService; - return sw ?? null; - } - - /// - /// Returns a ShrinkWraped mesh or + /// Returns a ShrinkWrapped mesh or /// null when a mesh was not created or error. /// - /// + /// + /// A ShrinkWrapParameters object that specifies the configuration settings for the ShrinkWrap process. + /// /// /// 8.0 public Mesh ShrinkWrap(ShrinkWrapParameters parameters) { - var sw = GetShrinkWrapPluginService(); - return sw.ShrinkWrap(this, parameters) ?? null; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(this, parameters); } /// - /// + /// Returns a ShrinkWrapped mesh or + /// null when a mesh was not created or error. /// - /// - /// + /// A ShrinkWrapParameters object that specifies the configuration settings for the ShrinkWrap process. + /// A cancellation token /// /// 8.0 public Mesh ShrinkWrap(ShrinkWrapParameters parameters, CancellationToken token) { - var sw = GetShrinkWrapPluginService(); - return sw.ShrinkWrap(this, parameters) ?? null; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(this, parameters); } /// - /// Creates a unified ShrinkWrap mesh from a collection of input meshes + /// Creates a unified ShrinkWrap mesh from a collection of input meshes. + /// Returns null on error or failure. /// /// - /// + /// A ShrinkWrapParameters object that specifies the configuration settings for the ShrinkWrap process. /// /// 8.0 public static Mesh ShrinkWrap(IEnumerable meshes, ShrinkWrapParameters parameters) { - var sw = GetShrinkWrapPluginService(); - return sw.ShrinkWrap(meshes, parameters) ?? null; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(meshes, parameters); } /// /// Creates a unified ShrinkWrap mesh from a point cloud + /// returns null on error or failure /// /// /// @@ -6258,21 +6269,21 @@ public static Mesh ShrinkWrap(IEnumerable meshes, ShrinkWrapParameters par /// 8.0 public static Mesh ShrinkWrap(PointCloud pointCloud, ShrinkWrapParameters parameters) { - var sw = GetShrinkWrapPluginService(); - return sw.ShrinkWrap(pointCloud, parameters) ?? null; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(pointCloud, parameters); } /// - /// Creates a unified ShrinkWrap mesh from a collection of geometry base objects + /// Creates a unified ShrinkWrap mesh from a collection of GeometryBase objects. + /// returns null or error on failure /// /// - /// - /// + /// A ShrinkWrapParameters object that specifies the configuration settings for the ShrinkWrap process. + /// GeometryBase objects are converted to meshes first using the MeshingParameters provided. Those meshes are then used in the ShrinkWrap process. /// + /// 8.3 public static Mesh ShrinkWrap(IEnumerable geometryBases, ShrinkWrapParameters parameters, MeshingParameters meshingParameters) { - var sw = GetShrinkWrapPluginService(); - return sw.ShrinkWrap(geometryBases, parameters,meshingParameters) ?? null; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(geometryBases, parameters, meshingParameters); } @@ -6803,6 +6814,7 @@ internal MeshUnsafeLock(Mesh parent, bool writable) /// The beginning of the vertex array. Item 0 is the first vertex, /// and item length-1 is the last valid one. /// The mesh does not have vertex normals. + /// 8.1 [CLSCompliant(false)] public unsafe int* VertexColorsArray(out int length) { @@ -6857,6 +6869,7 @@ internal MeshUnsafeLock(Mesh parent, bool writable) /// The beginning of the vertex array. Item 0 is the first vertex, /// and item length-1 is the last valid one. /// The mesh does not have face normals. + /// 8.1 [CLSCompliant(false)] public unsafe Vector3f* FaceNormalsArray(out int length) { @@ -11172,10 +11185,11 @@ public int Add(int red, int green, int blue) SetColor(Count, red, green, blue); return Count - 1; } + /// /// Adds a new vertex color to the end of the color list. /// - /// Color to append, Alpha channels will be ignored. + /// Color to append. /// The index of the newly added color. /// 5.0 public int Add(Color color) @@ -11184,6 +11198,18 @@ public int Add(Color color) return Count - 1; } + /// + /// Adds an enumerable of colors to the to the vertex color list. + /// For the Mesh to be valid, the number of colors must match the number of vertices. + /// + /// Colors to append. + /// true on success, false on failure. + /// 8.12 + public bool AddRange(IEnumerable colors) + { + return SetColorsHelper(colors.ToArray(), true); + } + /// /// Sets or adds a vertex color to the color List. /// If [index] is less than [Count], the existing vertex at [index] will be modified. @@ -13794,6 +13820,28 @@ public MeshDisplacementInfo(RenderTexture texture, namespace Rhino.Runtime { + /// + /// Internal class used by ShrinkWrap functions to acces the instance. + /// + internal static class ShrinkWrap + { + private static readonly Guid PluginId = new Guid("768DD816-C492-48B4-8C1D-28665571F281"); + private static readonly object Lock = new object(); + + /// + /// Get the shrinkwrap plugin and pass back the shrinkwrap interface + /// + /// + public static IShrinkWrapService Service() + { + lock (Lock) + { + object obj = RhinoApp.GetPlugInObject(PluginId); + return obj as IShrinkWrapService; + } + } + } + /// /// Internal interface used by ShrinkWrap functions /// @@ -13837,6 +13885,7 @@ public interface IShrinkWrapService /// /// /// + /// 8.3 Mesh ShrinkWrap(IEnumerable geometryBases, ShrinkWrapParameters parameters, MeshingParameters meshingParameters); } } diff --git a/src/dotnet/opennurbs/opennurbs_object.cs b/src/dotnet/opennurbs/opennurbs_object.cs index 65df942ed..f30e0d4ea 100644 --- a/src/dotnet/opennurbs/opennurbs_object.cs +++ b/src/dotnet/opennurbs/opennurbs_object.cs @@ -532,7 +532,7 @@ public bool Disposed { try { - return m_disposed || (m_ptr == IntPtr.Zero && _InternalGetConstPointer() == IntPtr.Zero); + return m_disposed || (m_ptr == IntPtr.Zero && ConstPointer() == IntPtr.Zero); } catch (DocumentCollectedException) { diff --git a/src/dotnet/opennurbs/opennurbs_planesurface.cs b/src/dotnet/opennurbs/opennurbs_planesurface.cs index 52ef07b59..395338951 100644 --- a/src/dotnet/opennurbs/opennurbs_planesurface.cs +++ b/src/dotnet/opennurbs/opennurbs_planesurface.cs @@ -29,6 +29,7 @@ public PlaneSurface() /// Constructs a new plane surface. /// /// The plane. + /// 8.1 public PlaneSurface(Plane plane) { IntPtr ptr = UnsafeNativeMethods.ON_PlaneSurface_New2(ref plane); @@ -187,6 +188,32 @@ public static PlaneSurface CreateThroughBox(Plane plane, BoundingBox box) [Serializable] public class ClippingPlaneSurface : PlaneSurface { + /// + /// Constructs an empty clipping plane surface + /// + public ClippingPlaneSurface() + { + IntPtr ptr = UnsafeNativeMethods.ON_ClippingPlaneSurface_New(); + ConstructNonConstObject(ptr); + } + /// + /// Constructs a clipping plane surface from a Plane + /// + /// + public ClippingPlaneSurface(Plane plane) + { + IntPtr ptr = UnsafeNativeMethods.ON_ClippingPlaneSurface_New_FromPlane(ref plane); + ConstructNonConstObject(ptr); + } + /// + /// Constructs a ClippingPlaneSurface from a PlaneSurface + /// + /// + public ClippingPlaneSurface(PlaneSurface planeSurface) + { + IntPtr ptr = UnsafeNativeMethods.ON_ClippingPlaneSurface_New_FromPLaneSurface(planeSurface.ConstPointer()); + ConstructNonConstObject(ptr); + } internal ClippingPlaneSurface(IntPtr ptr, object parent) : base(ptr, parent) { } diff --git a/src/dotnet/opennurbs/opennurbs_point.cs b/src/dotnet/opennurbs/opennurbs_point.cs index fcea4dd84..bebbd2724 100644 --- a/src/dotnet/opennurbs/opennurbs_point.cs +++ b/src/dotnet/opennurbs/opennurbs_point.cs @@ -1899,7 +1899,7 @@ public double MinimumCoordinate /// /// Gets the largest (both positive and negative) valid coordinate in this point, - /// or RhinoMath.UnsetValue if no coordinate is valid. + /// or RhinoMath.UnsetValue if no coordinate is valid, as an absolute value. /// /// 5.0 public double MaximumCoordinate @@ -3957,7 +3957,7 @@ public double MinimumCoordinate } /// - /// Gets the largest (both positive and negative) component value in this vector. + /// Gets the largest (both positive and negative) component value in this vector, as an absolute value. /// /// 5.0 public double MaximumCoordinate diff --git a/src/dotnet/opennurbs/opennurbs_pointcloud.cs b/src/dotnet/opennurbs/opennurbs_pointcloud.cs index 90e97b071..9be320304 100644 --- a/src/dotnet/opennurbs/opennurbs_pointcloud.cs +++ b/src/dotnet/opennurbs/opennurbs_pointcloud.cs @@ -990,14 +990,7 @@ public int RemoveRange(IEnumerable indices) /// 8.0 public Mesh ShrinkWrap(ShrinkWrapParameters parameters) { - var plugin_id = new Guid("768DD816-C492-48B4-8C1D-28665571F281"); - var obj = Rhino.RhinoApp.GetPlugInObject(plugin_id); - if (!(obj is IShrinkWrapService sw)) - return null; - - var mesh = sw.ShrinkWrap(this, parameters); - - return mesh; + return Runtime.ShrinkWrap.Service()?.ShrinkWrap(this, parameters); } /// diff --git a/src/dotnet/opennurbs/opennurbs_polylinecurve.cs b/src/dotnet/opennurbs/opennurbs_polylinecurve.cs index b8c870730..6a41256d9 100644 --- a/src/dotnet/opennurbs/opennurbs_polylinecurve.cs +++ b/src/dotnet/opennurbs/opennurbs_polylinecurve.cs @@ -129,7 +129,7 @@ out int[] hullIndices ) { int dim = 0; using (var resArray = new Rhino.Runtime.InteropWrappers.SimpleArrayInt()) { - IntPtr plc = UnsafeNativeMethods.RHC_ConvexHull2d( + IntPtr plc = UnsafeNativeMethods.RHC_ConvexHull2d_R8SR11( points, points.Length, resArray.NonConstPointer(), @@ -240,5 +240,23 @@ public Polyline ToPolyline() return Polyline.PolyLineFromNativeArray(output_points); } } + + /// + /// Returns the underlying Polyline points as an array. + /// + /// An array of 3d points. + /// 8.9 + public Point3d[] ToArray() + { + IntPtr const_ptr_this = ConstPointer(); + using (var output_points = new SimpleArrayPoint3d()) + { + IntPtr output_points_ptr = output_points.NonConstPointer(); + UnsafeNativeMethods.ON_PolylineCurve_CopyValues(const_ptr_this, output_points_ptr); + if (output_points.Count > 0) + return output_points.ToArray(); + return Array.Empty(); + } + } } } diff --git a/src/dotnet/opennurbs/opennurbs_rtree.cs b/src/dotnet/opennurbs/opennurbs_rtree.cs index 511e6b000..e15a0f23b 100644 --- a/src/dotnet/opennurbs/opennurbs_rtree.cs +++ b/src/dotnet/opennurbs/opennurbs_rtree.cs @@ -411,6 +411,12 @@ private static int CustomSearchCallback(int serial_number, IntPtr idA, IntPtr id /// /// true if entire tree was searched. It is possible no results were found. /// + /// + /// Do not modify the tree while a Search() is in progress. Doing so can + /// have unintended consequences, including corruption and crashes.If you + /// need to modify the tree, collect the results during the search and modify + /// the tree once the search is completed. + /// /// 5.0 public bool Search(BoundingBox box, EventHandler callback) { @@ -427,6 +433,12 @@ public bool Search(BoundingBox box, EventHandler callback) /// /// true if entire tree was searched. It is possible no results were found. /// + /// + /// Do not modify the tree while a Search() is in progress. Doing so can + /// have unintended consequences, including corruption and crashes.If you + /// need to modify the tree, collect the results during the search and modify + /// the tree once the search is completed. + /// /// 5.0 public bool Search(BoundingBox box, EventHandler callback, object tag) { @@ -460,6 +472,12 @@ public bool Search(BoundingBox box, EventHandler callback, objec /// /// true if entire tree was searched. It is possible no results were found. /// + /// + /// Do not modify the tree while a Search() is in progress. Doing so can + /// have unintended consequences, including corruption and crashes.If you + /// need to modify the tree, collect the results during the search and modify + /// the tree once the search is completed. + /// /// 5.0 public bool Search(Sphere sphere, EventHandler callback) { @@ -475,6 +493,12 @@ public bool Search(Sphere sphere, EventHandler callback) /// /// true if entire tree was searched. It is possible no results were found. /// + /// + /// Do not modify the tree while a Search() is in progress. Doing so can + /// have unintended consequences, including corruption and crashes.If you + /// need to modify the tree, collect the results during the search and modify + /// the tree once the search is completed. + /// /// /// /// @@ -518,6 +542,12 @@ public bool Search(Sphere sphere, EventHandler callback, object /// /// true if entire tree was searched. It is possible no results were found. /// + /// + /// Do not modify the tree while a Search() is in progress. Doing so can + /// have unintended consequences, including corruption and crashes.If you + /// need to modify the tree, collect the results during the search and modify + /// the tree once the search is completed. + /// /// 5.0 public static bool SearchOverlaps(RTree treeA, RTree treeB, double tolerance, EventHandler callback) { diff --git a/src/dotnet/opennurbs/opennurbs_subd.cs b/src/dotnet/opennurbs/opennurbs_subd.cs index 558b6ba41..48b91a6e7 100644 --- a/src/dotnet/opennurbs/opennurbs_subd.cs +++ b/src/dotnet/opennurbs/opennurbs_subd.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Linq; using System.Runtime.Serialization; using Rhino.Runtime; using Rhino.Runtime.InteropWrappers; @@ -217,6 +218,29 @@ public Curve[] DuplicateEdgeCurves(bool boundaryOnly, bool interiorOnly, bool sm UnsafeNativeMethods.ON_SubD_DuplicateEdgeCurves(const_ptr_this, ptr_output, boundaryOnly, interiorOnly, smoothOnly, sharpOnly, creaseOnly, clampEnds); return output.ToNonConstArray(); } + + /// + /// Transforms an enumerable of SubD components. + /// + /// The SubD components to transform. + /// The transformation to apply. + /// + /// Select between applying the transform to the control net (faster) or the surface points (slower). + /// + /// The number of vertex locations that changed. + /// + /// This method does not clear the evaluation cache. + /// + /// 8.12 + [CLSCompliant(false)] + public uint TransformComponents(IEnumerable components, Transform xform, SubDComponentLocation componentLocation) + { + IntPtr ptr_this = NonConstPointer(); + ComponentIndex[] arr_components = components.ToArray(); + uint rc = UnsafeNativeMethods.ON_SubD_TransformComponents(ptr_this, ref xform, arr_components.Length, arr_components, componentLocation); + return rc; + } + #endif /// @@ -935,6 +959,28 @@ public uint UpdateSurfaceMeshCache(bool lazyUpdate) } } + /// + /// Checks that a surface mesh evaluation cache exists, and that it has the required options. + /// This cache is used by + /// - , + /// - , and + /// - . + /// + /// If True, the cache must contain texture coordinates information. + /// If True, the cache must contain curvature information. + /// If True, the cache must contain color information. + /// True if the cache exists on all face fragments and has the required options. + /// This does not check that the cache is up to date, . + /// + /// + /// 8.9 + [CLSCompliant(false)] + public bool SurfaceMeshCacheExists(bool bTextureCoordinatesExist, bool bCurvaturesExist, bool bColorsExist) + { + var const_ptr_this = ConstPointer(); + return UnsafeNativeMethods.ON_SubD_SurfaceMeshCacheExists(const_ptr_this, bTextureCoordinatesExist, bCurvaturesExist, bColorsExist); + } + /// /// Returns a SubDComponent, either a SubDEdge, SubDFace, or SubDVertex, from a component index. /// @@ -2446,7 +2492,7 @@ internal override IntPtr UpdatePointer() } #region properties - /// Number of faces for this edge + /// Number of faces for this edge. /// 7.0 public int FaceCount { @@ -2458,7 +2504,21 @@ public int FaceCount } /// - /// Line representing the control net end points + /// Gets the component index of this edge. + /// + /// The component index. + /// 8.12 + [ConstOperation] + public ComponentIndex ComponentIndex() + { + ComponentIndex ci = new ComponentIndex(); + IntPtr const_edge_ptr = ConstPointer(); + UnsafeNativeMethods.ON_SubDEdge_ComponentIndex(const_edge_ptr, ref ci); + return ci; + } + + /// + /// Line representing the control net end points. /// /// 7.0 public Line ControlNetLine @@ -2470,7 +2530,7 @@ public Line ControlNetLine } /// - /// Start vertex for this edge + /// Start vertex for this edge. /// /// 7.0 public SubDVertex VertexFrom @@ -2487,7 +2547,7 @@ public SubDVertex VertexFrom } /// - /// End vertex for this edge + /// End vertex for this edge. /// /// 7.0 public SubDVertex VertexTo @@ -2504,7 +2564,7 @@ public SubDVertex VertexTo } /// - /// identifies the type of subdivision edge + /// identifies the type of subdivision edge. /// /// 7.0 public SubDEdgeTag Tag @@ -2524,7 +2584,7 @@ public SubDEdgeTag Tag #endregion /// - /// Retrieve a SubDFace from this edge + /// Retrieve a SubDFace from this edge. /// /// /// diff --git a/src/dotnet/opennurbs/opennurbs_texture.cs b/src/dotnet/opennurbs/opennurbs_texture.cs index 86f0b23a0..f0e7f0bcd 100644 --- a/src/dotnet/opennurbs/opennurbs_texture.cs +++ b/src/dotnet/opennurbs/opennurbs_texture.cs @@ -439,6 +439,7 @@ public int MappingChannelId /// /// How texture is projected onto geometry /// + /// 8.3 public TextureProjectionModes ProjectionMode { get @@ -456,6 +457,7 @@ public TextureProjectionModes ProjectionMode /// Notice: If this texture is used by an object that has an object coordinate system (OCS) frame /// defined on a mapping channel then that OCS frame is used instead of the WCS. /// + /// 8.3 public bool WcsProjected { get @@ -468,6 +470,7 @@ public bool WcsProjected /// If false, the texture color values should be correctly by the linear workflow pre-process gamma value (in the document) /// if linear workflow is on. Otherwise, if the values is true, the values should be used raw from the texture. /// + /// 8.7 public bool TreatAsLinear { get @@ -485,6 +488,7 @@ public bool TreatAsLinear /// Notice: If this texture is used by an object that has an object coordinate system (OCS) frame /// defined on a mapping channel then that OCS frame is used instead of the WCS. /// + /// 8.3 public bool WcsBoxProjected { get diff --git a/src/dotnet/opennurbs/opennurbs_userdata.cs b/src/dotnet/opennurbs/opennurbs_userdata.cs index 8eb350c8e..5c75a5ef2 100644 --- a/src/dotnet/opennurbs/opennurbs_userdata.cs +++ b/src/dotnet/opennurbs/opennurbs_userdata.cs @@ -2,12 +2,14 @@ using System.Collections; using System.Collections.Generic; using System.IO; +using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Text; namespace Rhino.DocObjects.Custom { + /// /// Provides a base class for custom classes of information which may be attached to /// geometry or attribute classes. @@ -161,6 +163,7 @@ protected virtual void OnDuplicate(UserData source) { } private static DeleteUserDataCallback g_on_delete; private static ChangeSerialNumberCallback g_on_getchangeserialnumber; + [MonoPInvokeCallback(typeof(TransformUserDataCallback))] private static void OnTransformUserData(int serialNumber, ref Geometry.Transform xform) { UserData ud = FromSerialNumber(serialNumber); @@ -176,6 +179,8 @@ private static void OnTransformUserData(int serialNumber, ref Geometry.Transform } } } + + [MonoPInvokeCallback(typeof(ArchiveUserDataCallback))] private static int OnArchiveUserData(int serialNumber) { int rc = 0; //FALSE @@ -196,6 +201,7 @@ private static int OnArchiveUserData(int serialNumber) } return rc; } + [MonoPInvokeCallback(typeof(ReadWriteUserDataCallback))] private static int OnReadWriteUserData(int serialNumber, int writing, IntPtr pBinaryArchive) { int rc = 0; //FALSE @@ -222,6 +228,7 @@ private static int OnReadWriteUserData(int serialNumber, int writing, IntPtr pBi } return rc; } + [MonoPInvokeCallback(typeof(DuplicateUserDataCallback))] private static int OnDuplcateUserData(int serialNumber, IntPtr pNativeUserData) { int rc = 0; @@ -252,6 +259,7 @@ private static int OnDuplcateUserData(int serialNumber, IntPtr pNativeUserData) } return rc; } + [MonoPInvokeCallback(typeof(CreateUserDataCallback))] private static IntPtr OnCreateInstance(Guid managedTypeId) { IntPtr rc = IntPtr.Zero; @@ -283,6 +291,7 @@ private static IntPtr OnCreateInstance(Guid managedTypeId) } return rc; } + [MonoPInvokeCallback(typeof(DeleteUserDataCallback))] private static void OnDelete(int serialNumber) { UserData ud = FromSerialNumber(serialNumber); @@ -305,6 +314,7 @@ private static void OnDelete(int serialNumber) /// /// /// + [MonoPInvokeCallback(typeof(ChangeSerialNumberCallback))] private static uint OnGetChangeSerialNumber(int serialNumber, uint currentRemainder) { UserData ud = FromSerialNumber(serialNumber); diff --git a/src/dotnet/resolver.cs b/src/dotnet/resolver.cs index fd97044a6..6bd73f3c7 100644 --- a/src/dotnet/resolver.cs +++ b/src/dotnet/resolver.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Collections; using System.Runtime.InteropServices; +using System.Collections.Immutable; namespace Rhino.Runtime { diff --git a/src/dotnet/rhino/persistentsettingshooks.cs b/src/dotnet/rhino/persistentsettingshooks.cs index e7f091cf7..fcf15a3b2 100644 --- a/src/dotnet/rhino/persistentsettingshooks.cs +++ b/src/dotnet/rhino/persistentsettingshooks.cs @@ -67,6 +67,7 @@ internal static void SetHooks() // Get a specific PersistentSettings reference to attach to internal delegate uint GetPlugInPersistentSettingsPointerProc(Guid plugInId, uint pointerId, bool windowPositions); static internal GetPlugInPersistentSettingsPointerProc GetManagedPlugInPersistentSettingsPointerHook = GetManagedPlugInPersistentSettingsPointerFunc; + [MonoPInvokeCallback(typeof(GetPlugInPersistentSettingsPointerProc))] private static uint GetManagedPlugInPersistentSettingsPointerFunc(Guid plugInId, uint pointerId, bool windowPositions) { PersistentSettings settings; @@ -98,18 +99,28 @@ private static uint GetManagedPlugInPersistentSettingsPointerFunc(Guid plugInId, /// /// /// + [MonoPInvokeCallback(typeof(GetPlugInPersistentSettingsPointerProc))] static private uint GetPlugInPersistentSettingsPointerFunc(Guid plugInId, uint pointerId, bool windowPositions) { PlugInSettings plug_in_settings; if (pointerId == 0) { lock (g_dictionary_lock) + { g_dictionary.TryGetValue(plugInId, out plug_in_settings); + } } else { lock (g_plug_in_settings_read_lock) - g_plug_in_settings_read.TryGetValue(pointerId, out plug_in_settings); + { + bool check = g_plug_in_settings_read.TryGetValue(pointerId, out plug_in_settings); + + //ALB 2024.09.01 + //If this fires, it means that my fix for https://mcneel.myjetbrains.com/youtrack/issue/RH-82124/Memory-leak-with-PersistentSettings + //is incorrect. Please log as much information in the bug about what you did, and the callstack and reopen the bug. + System.Diagnostics.Debug.Assert(check); + } } if (plug_in_settings == null) return 0; @@ -132,6 +143,7 @@ static internal PlugInSettings GetPlugInSettings(Guid plugInId) } internal delegate uint GetChildPersistentSettingsPointerProc(uint parentPointerId, IntPtr stringPointerChildName); static internal GetChildPersistentSettingsPointerProc GetChildPersistentSettingsHook = GetChildPersistentSettingsFunc; + [MonoPInvokeCallback(typeof(GetChildPersistentSettingsPointerProc))] static private uint GetChildPersistentSettingsFunc(uint parentPointerId, IntPtr stringPointerChildName) { var child_name = IntPtrToString(stringPointerChildName); @@ -151,6 +163,7 @@ static private uint GetChildPersistentSettingsFunc(uint parentPointerId, IntPtr } } static internal GetChildPersistentSettingsPointerProc AddChildPersistentSettingsHook = AddChildPersistentSettingsFunc; + [MonoPInvokeCallback(typeof(GetChildPersistentSettingsPointerProc))] static private uint AddChildPersistentSettingsFunc(uint parentPointerId, IntPtr stringPointerChildName) { var child_name = IntPtrToString(stringPointerChildName); @@ -170,6 +183,7 @@ static private uint AddChildPersistentSettingsFunc(uint parentPointerId, IntPtr } } static internal GetChildPersistentSettingsPointerProc DeleteItemPersistentSettingsHook = DeleteItemPersistentSettingsFunc; + [MonoPInvokeCallback(typeof(GetChildPersistentSettingsPointerProc))] static private uint DeleteItemPersistentSettingsFunc(uint pointerId, IntPtr keyString) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -179,6 +193,7 @@ static private uint DeleteItemPersistentSettingsFunc(uint pointerId, IntPtr keyS } static internal GetChildPersistentSettingsPointerProc DeleteChildPersistentSettingsHook = DeleteChildPersistentSettingsFunc; + [MonoPInvokeCallback(typeof(GetChildPersistentSettingsPointerProc))] static private uint DeleteChildPersistentSettingsFunc(uint parentPointerId, IntPtr stringPointerChildName) { var child_name = IntPtrToString(stringPointerChildName); @@ -200,6 +215,7 @@ static private uint DeleteChildPersistentSettingsFunc(uint parentPointerId, IntP } internal delegate uint GetCommandPersistentSettingsPointerProc(Guid plugInId, bool managedPlugIn, IntPtr stringPointerChildName); static internal GetCommandPersistentSettingsPointerProc GetCommandPersistentSettingsHook = GetCommandPersistentSettingsFunc; + [MonoPInvokeCallback(typeof(GetCommandPersistentSettingsPointerProc))] static private uint GetCommandPersistentSettingsFunc(Guid plugInId, bool managedPlugIn, IntPtr stringPointerCommandName) { var command_name = IntPtrToString(stringPointerCommandName); @@ -233,6 +249,7 @@ static private uint GetCommandPersistentSettingsFunc(Guid plugInId, bool managed } internal delegate void ReleasePlugInSettingsPointerProc(uint pointerId, bool readSettingsPointer); static internal ReleasePlugInSettingsPointerProc ReleasePlugInSettingsPointerHook = ReleasePlugInSettingsPointerFunc; + [MonoPInvokeCallback(typeof(ReleasePlugInSettingsPointerProc))] static private void ReleasePlugInSettingsPointerFunc(uint pointerId, bool readSettingsPointer) { lock (g_plug_in_settings_read_lock) @@ -287,6 +304,12 @@ internal static void InvokeSetingsSaved(Guid plugInId, bool thisRhinoIsSaving, b g_settings_saved(plugInId, pointer_id, thisRhinoIsSaving); // Invoke the changed call back on the main thread //RhinoApp.InvokeOnUiThread(g_settings_saved, plugInId, pointer_id, thisRhinoIsSaving); + + // ALB 2024.09.01 + //https://mcneel.myjetbrains.com/youtrack/issue/RH-82124/Memory-leak-with-PersistentSettings + //The change above made it possible to release the plug-in settings here, synchonously. I think + //this is now the correct fix, but if the invoke comes back, then it might need to be thought through again + ReleasePlugInSettingsPointerFunc(pointer_id, true); } private delegate void SettingsSavedDelegate(Guid plugInId, uint pointerId, bool thisRhinoIsSaving); private static readonly SettingsSavedDelegate g_settings_saved = OnSettingsSaved; @@ -299,6 +322,7 @@ private static void OnSettingsSaved(Guid plugInId, uint pointerId, bool thisRhin #region Create plug-in settings hook internal delegate int CreateDelegate(Guid plugInId); internal static CreateDelegate CreateHook = Create; + [MonoPInvokeCallback(typeof(CreateDelegate))] private static int Create(Guid plugInId) { if (plugInId == Guid.Empty) return 0; @@ -330,6 +354,7 @@ private static int Create(Guid plugInId) #region Save settings hook internal delegate int SaveDelegate(Guid plugInId, bool shuttingDown); internal static SaveDelegate SaveHook = Save; + [MonoPInvokeCallback(typeof(SaveDelegate))] private static int Save(Guid plugInId, bool shuttingDown) { var settings = PlugInSettings(plugInId); @@ -342,6 +367,7 @@ private static int Save(Guid plugInId, bool shuttingDown) internal delegate void FlushSavedDelegate(); internal static FlushSavedDelegate FlushSavedHook = FlushSaved; + [MonoPInvokeCallback(typeof(FlushSavedDelegate))] private static void FlushSaved() { Rhino.PlugInSettings.FlushSettingsSavedQueue(); @@ -350,6 +376,7 @@ private static void FlushSaved() internal delegate int GetKeysDelegate(uint pointerId, IntPtr keysPointer, bool children); internal static GetKeysDelegate GetKeysHook = GetKeys; + [MonoPInvokeCallback(typeof(GetKeysDelegate))] private static int GetKeys(uint pointerId, IntPtr keysPointer, bool children) { var settings = PersistentSettings(pointerId); @@ -393,6 +420,7 @@ private SetGetHelper(PersistentSettings settings, string key) #region Set... hooks internal delegate int SetStringDelegate(uint pointerId, IntPtr keyString, bool setDefault, IntPtr value); internal static SetStringDelegate SetStringHook = SetString; + [MonoPInvokeCallback(typeof(SetStringDelegate))] private static int SetString(uint pointerId, IntPtr keyString, bool setDefault, IntPtr value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -407,6 +435,7 @@ private static int SetString(uint pointerId, IntPtr keyString, bool setDefault, internal delegate int SetRectDelegate(uint pointerId, IntPtr keyString, bool setDefault, int left, int top, int right, int bottom); internal static SetRectDelegate SetRectHook = SetRect; + [MonoPInvokeCallback(typeof(SetRectDelegate))] private static int SetRect(uint pointerId, IntPtr keyString, bool setDefault, int left, int top, int right, int bottom) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -421,6 +450,7 @@ private static int SetRect(uint pointerId, IntPtr keyString, bool setDefault, in internal delegate int SetPointDelegate(uint pointerId, IntPtr keyString, bool setDefault, int x, int y); internal static SetPointDelegate SetPointHook = SetPoint; + [MonoPInvokeCallback(typeof(SetPointDelegate))] private static int SetPoint(uint pointerId, IntPtr keyString, bool setDefault, int x, int y) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -434,6 +464,7 @@ private static int SetPoint(uint pointerId, IntPtr keyString, bool setDefault, i } internal static SetPointDelegate SetSizeHook = SetSize; + [MonoPInvokeCallback(typeof(SetPointDelegate))] private static int SetSize(uint pointerId, IntPtr keyString, bool setDefault, int x, int y) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -448,6 +479,7 @@ private static int SetSize(uint pointerId, IntPtr keyString, bool setDefault, in internal delegate int SetIntegerDelegate(uint pointerId, IntPtr keyString, bool setDefault, int value); internal static SetIntegerDelegate SetIntegerHook = SetInteger; + [MonoPInvokeCallback(typeof(SetIntegerDelegate))] private static int SetInteger(uint pointerId, IntPtr keyString, bool setDefault, int value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -461,6 +493,7 @@ private static int SetInteger(uint pointerId, IntPtr keyString, bool setDefault, internal delegate int SetUnsignedIntegerDelegate(uint pointerId, IntPtr keyString, bool setDefault, uint value); internal static SetUnsignedIntegerDelegate SetUnsignedIntegerHook = SetUnsignedInteger; + [MonoPInvokeCallback(typeof(SetUnsignedIntegerDelegate))] private static int SetUnsignedInteger(uint pointerId, IntPtr keyString, bool setDefault, uint value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -488,6 +521,7 @@ private static string[] StringArrayFromIntPtr(IntPtr ptr) internal delegate int SetStringListDelegate(uint pointerId, IntPtr keyString, bool setDefault, IntPtr value); internal static SetStringListDelegate SetStringListHook = SetStringList; + [MonoPInvokeCallback(typeof(SetStringListDelegate))] private static int SetStringList(uint pointerId, IntPtr keyString, bool setDefault, IntPtr value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -502,6 +536,7 @@ private static int SetStringList(uint pointerId, IntPtr keyString, bool setDefau internal delegate int SetStringDictionaryDelegate(uint pointerId, IntPtr keyString, bool setDefault, IntPtr keys, IntPtr values); internal static SetStringDictionaryDelegate SetStringDictionaryHook = SetStringDictionary; + [MonoPInvokeCallback(typeof(SetStringDictionaryDelegate))] private static int SetStringDictionary(uint pointerId, IntPtr keyString, bool setDefault, IntPtr keys, IntPtr values) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -521,6 +556,7 @@ private static int SetStringDictionary(uint pointerId, IntPtr keyString, bool se internal delegate int SetDoubleDelegate(uint pointerId, IntPtr keyString, bool setDefault, double value); internal static SetDoubleDelegate SetDoubleHook = SetDouble; + [MonoPInvokeCallback(typeof(SetDoubleDelegate))] private static int SetDouble(uint pointerId, IntPtr keyString, bool setDefault, double value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -533,6 +569,7 @@ private static int SetDouble(uint pointerId, IntPtr keyString, bool setDefault, } internal static SetIntegerDelegate SetBoolHook = SetBool; + [MonoPInvokeCallback(typeof(SetIntegerDelegate))] private static int SetBool(uint pointerId, IntPtr keyString, bool setDefault, int value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -545,6 +582,7 @@ private static int SetBool(uint pointerId, IntPtr keyString, bool setDefault, in } internal static SetIntegerDelegate SetHideHook = SetHide; + [MonoPInvokeCallback(typeof(SetIntegerDelegate))] private static int SetHide(uint pointerId, IntPtr keyString, bool setDefault, int value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -555,6 +593,7 @@ private static int SetHide(uint pointerId, IntPtr keyString, bool setDefault, in internal delegate int PersistentSettingsHiddenProc(uint pointerId, ref int hide); internal static PersistentSettingsHiddenProc SetPersistentSettingsHiddenHook = SetPersistentSettingsHidden; + [MonoPInvokeCallback(typeof(PersistentSettingsHiddenProc))] private static int SetPersistentSettingsHidden(uint pointerId, ref int hide) { var settings = PersistentSettings(pointerId); @@ -564,6 +603,7 @@ private static int SetPersistentSettingsHidden(uint pointerId, ref int hide) } internal static SetIntegerDelegate SetColorHook = SetColor; + [MonoPInvokeCallback(typeof(SetIntegerDelegate))] private static int SetColor(uint pointerId, IntPtr keyString, bool setDefault, int abgr) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -581,6 +621,7 @@ private static int SetColor(uint pointerId, IntPtr keyString, bool setDefault, i internal delegate int SetGuidDelegate(uint pointerId, IntPtr keyString, bool setDefault, Guid value); internal static SetGuidDelegate SetGuidHook = SetGuid; + [MonoPInvokeCallback(typeof(SetGuidDelegate))] private static int SetGuid(uint pointerId, IntPtr keyString, bool setDefault, Guid value) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -594,6 +635,7 @@ private static int SetGuid(uint pointerId, IntPtr keyString, bool setDefault, Gu internal delegate int SetPoint3DDelegate(uint pointerId, IntPtr keyString, bool setDefault, ref Point3d point); internal static SetPoint3DDelegate SetPoint3DHook = SetPoint3D; + [MonoPInvokeCallback(typeof(SetPoint3DDelegate))] private static int SetPoint3D(uint pointerId, IntPtr keyString, bool setDefault, ref Point3d point) { var helper = SetGetHelper.OkayToGetOrSetValue(pointerId, keyString); @@ -610,6 +652,7 @@ private static int SetPoint3D(uint pointerId, IntPtr keyString, bool setDefault, #region Get... hooks internal delegate int GetStringDelegate(uint pointerId, IntPtr keyString, IntPtr value, bool useDefault, IntPtr defaultValue, IntPtr legacyKeyList, int count); internal static GetStringDelegate GetStringHook = GetString; + [MonoPInvokeCallback(typeof(GetStringDelegate))] private static int GetString(uint pointerId, IntPtr keyString, IntPtr value, bool useDefault, IntPtr defaultValue, IntPtr legacyKeyList, int count) { try @@ -642,6 +685,7 @@ internal delegate int GetRectDelegate( IntPtr legacyKeyList, int count); internal static GetRectDelegate GetRectHook = GetRect; + [MonoPInvokeCallback(typeof(GetRectDelegate))] private static int GetRect( uint pointerId, IntPtr keyString, @@ -679,6 +723,7 @@ private static int GetRect( internal delegate int GetPointDelegate(uint pointerId, IntPtr keyString, ref int x, ref int y, bool useDefault, int defaultX, int defaultY, IntPtr legacyKeyList, int count); internal static GetPointDelegate GetPointHook = GetPoint; + [MonoPInvokeCallback(typeof(GetPointDelegate))] private static int GetPoint(uint pointerId, IntPtr keyString, ref int x, ref int y, bool useDefault, int defaultX, int defaultY, IntPtr legacyKeyList, int count) { try @@ -706,6 +751,7 @@ private static int GetPoint(uint pointerId, IntPtr keyString, ref int x, ref int } internal static GetPointDelegate GetSizeHook = GetSize; + [MonoPInvokeCallback(typeof(GetPointDelegate))] private static int GetSize(uint pointerId, IntPtr keyString, ref int x, ref int y, bool useDefault, int defaultX, int defaultY, IntPtr legacyKeyList, int count) { try @@ -734,6 +780,7 @@ private static int GetSize(uint pointerId, IntPtr keyString, ref int x, ref int internal delegate int GetIntegerDelegate(uint pointerId, IntPtr keyString, ref int value, bool useDefault, int defaultValue, IntPtr legacyKeyList, int count); internal static GetIntegerDelegate GetIntegerHook = GetInteger; + [MonoPInvokeCallback(typeof(GetIntegerDelegate))] private static int GetInteger(uint pointerId, IntPtr keyString, ref int value, bool useDefault, int defaultValue, IntPtr legacyKeyList, int count) { try @@ -754,6 +801,7 @@ private static int GetInteger(uint pointerId, IntPtr keyString, ref int value, b } internal delegate int GetUnsignedIntegerDelegate(uint pointerId, IntPtr keyString, ref uint value, bool useDefault, uint defaultValue, IntPtr legacyKeyList, int count); internal static GetUnsignedIntegerDelegate GetUnsignedIntegerHook = GetUnsignedInteger; + [MonoPInvokeCallback(typeof(GetUnsignedIntegerDelegate))] private static int GetUnsignedInteger(uint pointerId, IntPtr keyString, ref uint value, bool useDefault, uint defaultValue, IntPtr legacyKeyList, int count) { try @@ -774,6 +822,7 @@ private static int GetUnsignedInteger(uint pointerId, IntPtr keyString, ref uint } internal delegate int GetStringListDelegate(uint pointerId, IntPtr keyString, IntPtr value, bool useDefault, IntPtr defaultValue, IntPtr legacyKeyList, int count); internal static GetStringListDelegate GetStringListHook = GetStringList; + [MonoPInvokeCallback(typeof(GetStringListDelegate))] private static int GetStringList(uint pointerId, IntPtr keyString, IntPtr value, bool useDefault, IntPtr defaultValue, IntPtr legacyKeyList, int count) { try @@ -808,6 +857,7 @@ internal delegate int GetStringDictionaryDelegate( IntPtr legacyKeyList, int count); internal static GetStringDictionaryDelegate GetStringDictionaryHook = GetStringDictionary; + [MonoPInvokeCallback(typeof(GetStringDictionaryDelegate))] private static int GetStringDictionary( uint pointerId, IntPtr keyString, @@ -854,6 +904,7 @@ private static int GetStringDictionary( } internal delegate int GetDoubleDelegate(uint pointerId, IntPtr keyString, ref double value, bool useDefault, double defaultValue, IntPtr legacyKeyList, int count); internal static GetDoubleDelegate GetDoubleHook = GetDouble; + [MonoPInvokeCallback(typeof(GetDoubleDelegate))] private static int GetDouble(uint pointerId, IntPtr keyString, ref double value, bool useDefault, double defaultValue, IntPtr legacyKeyList, int count) { try @@ -873,6 +924,7 @@ private static int GetDouble(uint pointerId, IntPtr keyString, ref double value, } } internal static GetIntegerDelegate GetBoolHook = GetBool; + [MonoPInvokeCallback(typeof(GetIntegerDelegate))] private static int GetBool(uint pointerId, IntPtr keyString, ref int value, bool useDefault, int defaultValue, IntPtr legacyKeyList, int count) { try @@ -896,6 +948,7 @@ private static int GetBool(uint pointerId, IntPtr keyString, ref int value, bool } } internal static GetIntegerDelegate GetHideHook = GetHide; + [MonoPInvokeCallback(typeof(GetIntegerDelegate))] private static int GetHide(uint pointerId, IntPtr keyString, ref int value, bool useDefault, int defaultValue, IntPtr legacyKeyList, int count) { try @@ -913,6 +966,7 @@ private static int GetHide(uint pointerId, IntPtr keyString, ref int value, bool } } internal static PersistentSettingsHiddenProc PersistentSettingsHiddenHook = PersistentSettingsHidden; + [MonoPInvokeCallback(typeof(PersistentSettingsHiddenProc))] private static int PersistentSettingsHidden(uint pointerId, ref int hide) { var settings = PersistentSettings(pointerId); @@ -921,6 +975,7 @@ private static int PersistentSettingsHidden(uint pointerId, ref int hide) return 1; } internal static GetIntegerDelegate GetColorHook = GetColor; + [MonoPInvokeCallback(typeof(GetIntegerDelegate))] private static int GetColor(uint pointerId, IntPtr keyString, ref int value, bool useDefault, int defaultValue, IntPtr legacyKeyList, int count) { try @@ -944,6 +999,7 @@ private static int GetColor(uint pointerId, IntPtr keyString, ref int value, boo internal delegate int GetGuidDelegate(uint pointerId, IntPtr keyString, ref Guid value, bool useDefault, Guid defaultValue, IntPtr legacyKeyList, int count); internal static GetGuidDelegate GetGuidHook = GetGuid; + [MonoPInvokeCallback(typeof(GetGuidDelegate))] private static int GetGuid(uint pointerId, IntPtr keyString, ref Guid value, bool useDefault, Guid defaultValue, IntPtr legacyKeyList, int count) { try @@ -968,6 +1024,7 @@ private static int GetGuid(uint pointerId, IntPtr keyString, ref Guid value, boo internal delegate int GetPoint3DDelegate(uint pointerId, IntPtr keyString, ref Point3d value, bool useDefault, ref Point3d defaultValue, IntPtr legacyKeyList, int count); internal static GetPoint3DDelegate GetPoint3DHook = GetPoint3D; + [MonoPInvokeCallback(typeof(GetPoint3DDelegate))] private static int GetPoint3D(uint pointerId, IntPtr keyString, ref Point3d value, bool useDefault, ref Point3d defaultValue, IntPtr legacyKeyList, int count) { try diff --git a/src/dotnet/rhino/rhinosdkadvancedsettings.cs b/src/dotnet/rhino/rhinosdkadvancedsettings.cs index 967007533..1df373e3f 100644 --- a/src/dotnet/rhino/rhinosdkadvancedsettings.cs +++ b/src/dotnet/rhino/rhinosdkadvancedsettings.cs @@ -82,6 +82,7 @@ static internal bool HideMacStatusBarPopUpTextOnMouseDown static public void SetDarkModeToSystemValue() => DarkMode = UnsafeNativeMethods.RhColors_GetDefaultWindowsDarkMode(); + [MonoPInvokeCallback(typeof(PersistentSettingsHooks.DarkModeDelegate))] internal static bool SetGetDarkModeHook(bool value, bool set) { if (set) diff --git a/src/dotnet/rhino/rhinosdkapp.cs b/src/dotnet/rhino/rhinosdkapp.cs index a14228835..98543d278 100644 --- a/src/dotnet/rhino/rhinosdkapp.cs +++ b/src/dotnet/rhino/rhinosdkapp.cs @@ -6,6 +6,7 @@ using Rhino.ApplicationSettings; using Rhino.DocObjects; using Rhino.Geometry; +using Rhino.Runtime; using Rhino.Runtime.InteropWrappers; namespace Rhino.ApplicationSettings @@ -1386,6 +1387,15 @@ public static bool IsInternetAccessAllowed } } + /// + /// Is the current thread the main thread + /// + /// 8.10 + public static bool IsOnMainThread + { + get { return GetBool(UnsafeNativeMethods.RhinoAppBool.IsOnMainThread); } + } + /// /// Returns true when Rhino is allowed to save, false otherwise /// Conditions where Rhino is not allowed to save are: when evaluation licenses are expired; @@ -1661,6 +1671,7 @@ public static event KeyboardHookEvent KeyboardEvent } private static RhCmnEmptyCallback m_OnInitApp; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnInitApp() => m_init_app.SafeInvoke(); internal static EventHandler m_init_app; @@ -1702,6 +1713,7 @@ public static event EventHandler Initialized private static RhCmnEmptyCallback m_OnCloseApp; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnCloseApp() => m_close_app?.SafeInvoke(); internal static EventHandler m_close_app; @@ -1741,6 +1753,7 @@ public static event EventHandler Closing private static RhCmnEmptyCallback m_OnAppSettingsChanged; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnAppSettingsChanged() => m_appsettings_changed?.SafeInvoke(); internal static EventHandler m_appsettings_changed; @@ -1779,6 +1792,7 @@ public static event EventHandler AppSettingsChanged } private static RhCmnEmptyCallback m_OnIdle; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnIdle() => m_idle_occured?.SafeInvoke(); private static EventHandler m_idle_occured; @@ -1828,6 +1842,7 @@ public static event EventHandler Idle } private static RhCmnEmptyCallback m_OnMainLoop; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnMainLoop() => m_main_loop_occured?.SafeInvoke(); private static EventHandler m_main_loop_occured; @@ -1886,6 +1901,7 @@ internal static void FireLicenseStateChangedEvent(object sender, Rhino.Runtime.N internal delegate void RhCmnOneUintCallback(uint docSerialNumber); private static RhCmnOneUintCallback m_OnNewRdkDocument; + [MonoPInvokeCallback(typeof(RhCmnOneUintCallback))] private static void OnNewRdkDocument(uint docSerialNumber) { m_new_rdk_document?.SafeInvoke(RhinoDoc.FromRuntimeSerialNumber(docSerialNumber)); @@ -1921,6 +1937,7 @@ public static event EventHandler RdkNewDocument private static RhCmnEmptyCallback m_OnRdkGlobalSettingsChanged; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnRdkGlobalSettingsChanged() => m_rdk_global_settings_changed?.SafeInvoke(); internal static EventHandler m_rdk_global_settings_changed; @@ -1952,6 +1969,7 @@ public static event EventHandler RdkGlobalSettingsChanged private static RhCmnOneUintCallback m_OnRdkUpdateAllPreviews; + [MonoPInvokeCallback(typeof(RhCmnOneUintCallback))] private static void OnRdkUpdateAllPreviews(uint docSerialNumber) { m_rdk_update_all_previews?.SafeInvoke(RhinoDoc.FromRuntimeSerialNumber(docSerialNumber)); @@ -1986,6 +2004,7 @@ public static event EventHandler RdkUpdateAllPreviews private static RhCmnEmptyCallback m_OnCacheImageChanged; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnRdkCacheImageChanged() => m_rdk_cache_image_changed?.SafeInvoke(); internal static EventHandler m_rdk_cache_image_changed; @@ -2016,6 +2035,7 @@ public static event EventHandler RdkCacheImageChanged } private static RhCmnEmptyCallback m_OnRendererChanged; + [MonoPInvokeCallback(typeof(RhCmnEmptyCallback))] private static void OnRendererChanged() => m_renderer_changed?.SafeInvoke(); internal static EventHandler m_renderer_changed; @@ -2049,6 +2069,7 @@ public static event EventHandler RendererChanged internal delegate void ClientPlugInUnloadingCallback(Guid plugIn); private static ClientPlugInUnloadingCallback m_OnClientPlugInUnloading; + [MonoPInvokeCallback(typeof(ClientPlugInUnloadingCallback))] private static void OnClientPlugInUnloading(Guid plugIn) => m_client_plugin_unloading?.SafeInvoke(); internal static EventHandler m_client_plugin_unloading; @@ -2130,12 +2151,12 @@ public static bool RunningInRdp() } /// - /// + /// Parses a text field string. /// - /// - /// - /// - /// + /// The text formula. + /// The Rhino object. Value can be IntPtr.Zero. + /// The parent Rhino object. Value can be IntPtr.Zero. + /// The parsed text field if sucessful. /// 6.0 public static string ParseTextField(string formula, RhinoObject obj, RhinoObject topParentObject ) { @@ -2154,6 +2175,37 @@ public static string ParseTextField(string formula, RhinoObject obj, RhinoObject return sh.ToString(); } } + + /// + /// Parses a text field string. + /// + /// The text formula. + /// The Rhino object. Value can be IntPtr.Zero. + /// The parent Rhino object. Value can be IntPtr.Zero. + /// The immediate parent instance object. Value can be IntPtr.Zero. + /// The parsed text field if sucessful. + /// 8.10 + public static string ParseTextField(string formula, RhinoObject obj, RhinoObject topParentObject, InstanceObject immediateParent) + { + if (topParentObject == null) + topParentObject = obj; + using (var sh = new Runtime.InteropWrappers.StringWrapper()) + { + IntPtr ptr_string = sh.NonConstPointer; + IntPtr ptr_obj = IntPtr.Zero; + if (obj != null) + ptr_obj = obj.ConstPointer(); + IntPtr ptr_parent_obj = IntPtr.Zero; + if (topParentObject != null) + ptr_parent_obj = topParentObject.ConstPointer(); + IntPtr ptr_immediate_parent_obj = IntPtr.Zero; + if (immediateParent != null) + ptr_immediate_parent_obj = immediateParent.ConstPointer(); + UnsafeNativeMethods.CRhinoApp_RhParseTextField2(formula, ptr_string, ptr_obj, ptr_parent_obj, ptr_immediate_parent_obj); + return sh.ToString(); + } + } + /// /// Post an enter event to the command line /// diff --git a/src/dotnet/rhino/rhinosdkappsettings.cs b/src/dotnet/rhino/rhinosdkappsettings.cs index 311e691ac..f7e6994d6 100644 --- a/src/dotnet/rhino/rhinosdkappsettings.cs +++ b/src/dotnet/rhino/rhinosdkappsettings.cs @@ -4,6 +4,7 @@ using Rhino.Runtime.InteropWrappers; using Rhino.Geometry; using System.Collections.Generic; +using Rhino.Runtime; namespace Rhino.ApplicationSettings { @@ -236,6 +237,7 @@ public static class AppearanceSettings { /// Set UI to the default dark mode color scheme /// true on sucess + /// 8.2 public static bool SetToDarkMode() { var service = Rhino.UI.RhinoUiServiceLocater.DialogService; @@ -246,6 +248,7 @@ public static bool SetToDarkMode() /// Set UI to the default light mode color scheme /// true on sucess + /// 8.2 public static bool SetToLightMode() { var service = Rhino.UI.RhinoUiServiceLocater.DialogService; @@ -258,6 +261,7 @@ public static bool SetToLightMode() /// Determine if Rhino is running with default dark mode color settings /// /// + /// 8.2 public static bool UsingDefaultDarkModeColors() { var service = Rhino.UI.RhinoUiServiceLocater.DialogService; @@ -273,6 +277,7 @@ public static bool UsingDefaultDarkModeColors() /// Determine if Rhino is running with default light mode color settings /// /// + /// 8.2 public static bool UsingDefaultLightModeColors() { var service = Rhino.UI.RhinoUiServiceLocater.DialogService; @@ -1428,7 +1433,7 @@ static DraftAngleAnalysisSettingsState CreateState(bool current) var up_direction = Vector3d.ZAxis; if (UnsafeNativeMethods.CRhinoDraftAngleAnalysisSettings_UpDirection(ptr_settings, ref up_direction, false)) - return rc; + rc.UpDirection = up_direction; UnsafeNativeMethods.CRhinoDraftAngleAnalysisSettings_Delete(ptr_settings); return rc; @@ -3040,6 +3045,7 @@ static bool GetBool(int which, IntPtr pSettings) const int idxStickyAutoCPlane = 20; const int idxGumballExtrudeMergeFaces = 21; const int idxOrientAutoCPlaneToView = 22; + const int idxGumballAutoReset = 23; ///Gets or sets the enabled state of Rhino's grid snap modeling aid. /// 5.0 @@ -3414,6 +3420,17 @@ public static bool GumballExtrudeMergeFaces get => GetBool(idxGumballExtrudeMergeFaces); set => SetBool(idxGumballExtrudeMergeFaces, value); } + + /// + /// When GumballAutoReset is on the gumball resets its orientation after a drag + /// When GumballAutoReset is off the gumball orientation is kept to where it was dragged + /// + /// 8.10 + public static bool GumballAutoReset + { + get => GetBool(idxGumballAutoReset); + set => SetBool(idxGumballAutoReset, value); + } } /// @@ -4871,11 +4888,93 @@ public enum ShortcutKey : int MacControlShiftF12, } + /// + /// A shortcut is a key plus modifier combination that executes a macro + /// + public class KeyboardShortcut + { + /// Modifier key used for shortcut + public Rhino.UI.ModifierKey Modifier { get; set; } = Rhino.UI.ModifierKey.None; + /// Key used for shortcut + public Rhino.UI.KeyboardKey Key { get; set; } = Rhino.UI.KeyboardKey.None; + /// Macro to execute when key plus modifier are pressed + public string Macro { get; set; } + } + /// /// Contains static methods and properties to control keyboard shortcut keys /// public static class ShortcutKeySettings { + + /// + /// Get all shortcuts registered with Rhino + /// + /// + public static KeyboardShortcut[] GetShortcuts() => GetShortcuts(UnsafeNativeMethods.CRhinoAppShortcutKeys_GetShortcuts); + + /// + /// Get all the default shortcuts registered with Rhino + /// + /// + public static KeyboardShortcut[] GetDefaults() => GetShortcuts(UnsafeNativeMethods.CRhinoAppShortcutKeys_GetDefaults); + + private static KeyboardShortcut[] GetShortcuts(Action shortcutGetter) + { + List rc = new List(); + using (var modifiers = new SimpleArrayInt()) + using (var keys = new SimpleArrayInt()) + using (var macros = new ClassArrayString()) + { + IntPtr ptrModifiers = modifiers.NonConstPointer(); + IntPtr ptrKeys = keys.NonConstPointer(); + IntPtr ptrMacros = macros.NonConstPointer(); + shortcutGetter(ptrModifiers, ptrKeys, ptrMacros); + int[] modifiersArray = modifiers.ToArray(); + int[] keysArray = keys.ToArray(); + string[] macrosArray = macros.ToArray(); + for (int i = 0; i < modifiersArray.Length; i++) + { + KeyboardShortcut shortcut = new KeyboardShortcut(); + shortcut.Modifier = (Rhino.UI.ModifierKey)modifiersArray[i]; + shortcut.Key = (Rhino.UI.KeyboardKey)keysArray[i]; + shortcut.Macro = macrosArray[i]; + rc.Add(shortcut); + } + } + return rc.ToArray(); + } + + /// + /// Add or modify shortcuts with a list or KeyboardShortcut elements + /// + /// + /// + public static void Update(IEnumerable shortcuts, bool replaceAll) + { + using (var macros = new ClassArrayString()) + { + List keys = new List(); + List modifiers = new List(); + foreach (var shortcut in shortcuts) + { + if (shortcut == null) + continue; + macros.Add(shortcut.Macro); + keys.Add((int)shortcut.Key); + modifiers.Add((int)shortcut.Modifier); + } + + if (keys.Count < 1) + return; + + int[] keyArray = keys.ToArray(); + int[] modifiersArray = modifiers.ToArray(); + IntPtr ptrMacros = macros.ConstPointer(); + UnsafeNativeMethods.CRhinoAppShortcutKeys_SetShortcuts(keyArray, modifiersArray, keyArray.Length, ptrMacros, replaceAll); + } + } + /// /// Get macro associated with a given keyboard shortcut /// @@ -4903,6 +5002,17 @@ public static void SetMacro(ShortcutKey key, string macro) UnsafeNativeMethods.CRhinoAppShortcutKeys_SetMacro((int)key, macro); } + /// + /// Set a macro for a given key and modifier combination + /// + /// + /// + /// + public static void SetMacro(Rhino.UI.KeyboardKey key, Rhino.UI.ModifierKey modifier, string macro) + { + UnsafeNativeMethods.CRhinoAppShortcutKeys_SetMacro2((int)key, (int)modifier, macro); + } + /// /// Get the macro label associated with a given keyboard shortcut /// @@ -4919,7 +5029,16 @@ public static string GetLabel(ShortcutKey key) } } - //CRhinoAppShortcutKeys_Label + /// + /// Is a key plus modifier combination one that can be used with Rhino + /// + /// + /// + /// + public static bool IsAcceptableKeyCombo(Rhino.UI.KeyboardKey key, Rhino.UI.ModifierKey modifier) + { + return UnsafeNativeMethods.CRhinoAppShortcutKeys_IsAcceptableCombo((int)key, (int)modifier); + } } /// diff --git a/src/dotnet/rhino/rhinosdkcommand.cs b/src/dotnet/rhino/rhinosdkcommand.cs index 2de8be6f6..83427c4ba 100644 --- a/src/dotnet/rhino/rhinosdkcommand.cs +++ b/src/dotnet/rhino/rhinosdkcommand.cs @@ -4,6 +4,7 @@ using System.Runtime.InteropServices; using System.Collections.Generic; using Rhino.Runtime.InteropWrappers; +using Rhino.Runtime; #if RHINO_SDK namespace Rhino.Commands @@ -348,7 +349,8 @@ public PersistentSettings Settings /// The command running mode. /// The command result code. protected abstract Result RunCommand(RhinoDoc doc, RunMode mode); - internal int OnRunCommand(int commandSerialNumber, uint docSerialNumber, int mode) + [MonoPInvokeCallback(typeof(RunCommandCallback))] + internal static int OnRunCommand(int commandSerialNumber, uint docSerialNumber, int mode) { Result rc = Result.Failure; try @@ -388,6 +390,7 @@ protected virtual void OnHelp() /// The default implementation return an empty string. /// protected virtual string CommandContextHelpUrl{ get { return string.Empty; } } + [MonoPInvokeCallback(typeof(DoHelpCallback))] static void OnDoHelp(int command_serial_number) { try @@ -401,6 +404,7 @@ static void OnDoHelp(int command_serial_number) Rhino.Runtime.HostUtils.ExceptionReport(ex); } } + [MonoPInvokeCallback(typeof(ContextHelpCallback))] static int OnCommandContextHelpUrl(int command_serial_number, IntPtr pON_wString) { int rc = 0; @@ -563,6 +567,7 @@ public static void DisplayHelp(Guid commandId) internal delegate void CommandCallback(IntPtr pCommand, int rc, uint docRuntimeSerialNumber); private static CommandCallback m_OnBeginCommand; private static CommandCallback m_OnEndCommand; + [MonoPInvokeCallback(typeof(CommandCallback))] private static void OnBeginCommand(IntPtr pCommand, int rc, uint docRuntimeSerialNumber) { if (m_begin_command != null) @@ -572,6 +577,7 @@ private static void OnBeginCommand(IntPtr pCommand, int rc, uint docRuntimeSeria e.m_pCommand = IntPtr.Zero; } } + [MonoPInvokeCallback(typeof(CommandCallback))] private static void OnEndCommand(IntPtr pCommand, int rc, uint docRuntimeSerialNumber) { if (m_end_command != null) @@ -643,6 +649,7 @@ public static event EventHandler EndCommand internal delegate void UndoCallback(int undo_event, uint undo_record_sn, Guid command_id); private static UndoCallback m_OnUndoEvent; + [MonoPInvokeCallback(typeof(UndoCallback))] private static void OnUndoEvent(int undo_event, uint undo_record_sn, Guid command_id) { if (m_undo_event != null) @@ -694,6 +701,7 @@ protected virtual bool ReplayHistory(Rhino.DocObjects.ReplayHistoryData replayDa { return false; } + [MonoPInvokeCallback(typeof(ReplayHistoryCallback))] private static int OnReplayHistory(int command_serial_number, IntPtr pConstRhinoHistoryRecord, IntPtr pObjectPairArray) { int rc = 0; @@ -778,6 +786,33 @@ public string CommandLocalName } } + string m_help_url = null; + /// + /// Gets the help url of the command that raised this event. + /// + /// + /// Null is a possible return. Calling function must check before using result. + /// m_help_url will get set only if the commmand has a ContextHelpURL override. + /// + /// 8.0 + public string CommandHelpURL + { + get + { + if (m_help_url == null) + { + using (var sh = new StringHolder()) + { + IntPtr pStringHolder = sh.NonConstPointer(); + if (true == UnsafeNativeMethods.CRhinoCommand_HelpURL(m_pCommand, pStringHolder)) + m_help_url = sh.ToString(); + } + } + return m_help_url; + } + } + + string m_plugin_name; /// /// Gets the name of the plug-in that this command belongs to. If the command is internal @@ -881,6 +916,7 @@ public abstract class SelCommand : Command /// The object to check regarding selection status. /// true if the object should be selected; false otherwise. protected abstract bool SelFilter(Rhino.DocObjects.RhinoObject rhObj); + [MonoPInvokeCallback(typeof(SelFilterCallback))] internal static int OnSelFilter(int commandSerialNumber, IntPtr pRhinoObject) { int rc = 0; @@ -910,6 +946,7 @@ internal static int OnSelFilter(int commandSerialNumber, IntPtr pRhinoObject) /// /// 7.9 protected virtual bool SelSubObjectFilter(Rhino.DocObjects.RhinoObject rhObj, List indicesToSelect) { return false; } + [MonoPInvokeCallback(typeof(SelSubObjectCallback))] internal static int OnSelSubObjectFilter(int commandSerialNumber, IntPtr pRhinoObject, IntPtr pComponentIndices) { bool rc = false; diff --git a/src/dotnet/rhino/rhinosdkdetailobject.cs b/src/dotnet/rhino/rhinosdkdetailobject.cs index ada7cf34d..b29d32e0e 100644 --- a/src/dotnet/rhino/rhinosdkdetailobject.cs +++ b/src/dotnet/rhino/rhinosdkdetailobject.cs @@ -1,5 +1,6 @@ #pragma warning disable 1591 using System; +using Rhino.Display; using Rhino.Geometry; using Rhino.Runtime.InteropWrappers; diff --git a/src/dotnet/rhino/rhinosdkdimstyle.cs b/src/dotnet/rhino/rhinosdkdimstyle.cs index acd711e72..4a2e0a777 100644 --- a/src/dotnet/rhino/rhinosdkdimstyle.cs +++ b/src/dotnet/rhino/rhinosdkdimstyle.cs @@ -1178,6 +1178,43 @@ public Guid ParentId #endregion field overrides +#region user strings + /// + /// Attach a user string (key,value combination) to this geometry. + /// + /// id used to retrieve this string. + /// string associated with key. + /// true on success. + /// 8.9 + public bool SetUserString(string key, string value) => _SetUserString(key, value); + + /// + /// Gets user string from this geometry. + /// + /// id used to retrieve the string. + /// string associated with the key if successful. null if no key was found. + /// 8.9 + public string GetUserString(string key) => _GetUserString(key); + + /// + /// Gets the amount of user strings. + /// + /// 8.9 + public int UserStringCount => _UserStringCount; + + /// + /// Gets a copy of all (user key string, user value string) pairs attached to this geometry. + /// + /// A new collection. + /// 8.9 + public System.Collections.Specialized.NameValueCollection GetUserStrings() => _GetUserStrings(); + + /// 8.9 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.9 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); +#endregion } } diff --git a/src/dotnet/rhino/rhinosdkdisplaypipeline.cs b/src/dotnet/rhino/rhinosdkdisplaypipeline.cs index 4a6e1c3ec..2ed490f4e 100644 --- a/src/dotnet/rhino/rhinosdkdisplaypipeline.cs +++ b/src/dotnet/rhino/rhinosdkdisplaypipeline.cs @@ -4,6 +4,7 @@ using System.Linq; using Rhino.DocObjects; using Rhino.Geometry; +using Rhino.Runtime; using Rhino.UI; namespace Rhino.Display @@ -979,6 +980,7 @@ public System.Drawing.Bitmap FrameBuffer /// true if a tiled capture is being performed. If false, the fullSize parameter will have the /// same size as currentTile /// + /// 8.2 public bool IsInTiledDraw(out System.Drawing.Size fullSize, out System.Drawing.Rectangle currentTile) { int fullWidth=0, fullHeight=0; @@ -2065,6 +2067,8 @@ public void DrawSubDShaded(SubD subd, DisplayMaterial material) /// 7.0 public void DrawSubDWires(SubD subd, System.Drawing.Color color, float thickness) { + if (subd == null) + return; int argb = color.ToArgb(); IntPtr const_ptr_subd = subd.ConstPointer(); IntPtr subd_display = subd.SubDDisplay(); @@ -2072,6 +2076,32 @@ public void DrawSubDWires(SubD subd, System.Drawing.Color color, float thickness GC.KeepAlive(subd); } + /// + /// Draws all the wireframe curves os a SubD object using different pens + /// + /// SubD to draw + /// Pen to use for boundary wires. If null, no boundary wires will be drawn + /// Pen to use for smooth interior wires. If null, no smooth interior wires will be drawn + /// Pen to use for crease wires. If null, no crease wires will be drawn + /// Pen to use for non-manifold wires. If null, no non-manifold wires will be drawn + public void DrawSubDWires(SubD subd, DisplayPen boundaryPen, DisplayPen smoothInteriorPen, DisplayPen creasePen, DisplayPen nonmanifoldPen) + { + if (subd == null) + return; + IntPtr const_ptr_subd = subd.ConstPointer(); + IntPtr subd_display = subd.SubDDisplay(); + IntPtr ptrBoundary = boundaryPen != null ? boundaryPen.ToNativePointer() : IntPtr.Zero; + IntPtr ptrSmoothInterior = smoothInteriorPen != null ? smoothInteriorPen.ToNativePointer() : IntPtr.Zero; + IntPtr ptrCrease = creasePen != null ? creasePen.ToNativePointer() : IntPtr.Zero; + IntPtr ptrNonmanifold = nonmanifoldPen != null ? nonmanifoldPen.ToNativePointer() : IntPtr.Zero; + UnsafeNativeMethods.CRhinoDisplayPipeline_DrawSubDWires2(m_ptr, const_ptr_subd, subd_display, ptrBoundary, ptrSmoothInterior, ptrCrease, ptrNonmanifold); + DisplayPen.DeleteNativePointer(ptrBoundary); + DisplayPen.DeleteNativePointer(ptrSmoothInterior); + DisplayPen.DeleteNativePointer(ptrCrease); + DisplayPen.DeleteNativePointer(ptrNonmanifold); + GC.KeepAlive(subd); + } + /// /// Draws a shaded mesh representation of a brep. /// diff --git a/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs b/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs index 0180095cc..d18f44dd8 100644 --- a/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs +++ b/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs @@ -100,7 +100,7 @@ internal void CopyContents(DisplayPipelineAttributes other) UnsafeNativeMethods.CDisplayPipelineAttributes_CopyContents(ptr_this, const_ptr_other); } #endregion - + protected DisplayPipelineAttributes(SerializationInfo info, StreamingContext context) { m_parent = null; @@ -135,7 +135,7 @@ public void Dispose() protected virtual void Dispose(bool disposing) { - if (m_ptr_attributes!=IntPtr.Zero && !m_dontdelete) + if (m_ptr_attributes != IntPtr.Zero && !m_dontdelete) { UnsafeNativeMethods.CDisplayPipelineAttributes_Delete(m_ptr_attributes); } @@ -613,22 +613,38 @@ public bool UseSingleCurveColor set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleCurveColor, value); } } + /// 8.6 public enum CurveThicknessUse : int { ObjectWidth = 0, Pixels = 1 } + /// + /// Use a pixel thickness (CurveThickness) or a scale thickness (CurveThicknessScale) + /// + /// 8.4 + public CurveThicknessUse CurveThicknessUsage + { + get { return (CurveThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage, (int)value); } + } + /// /// Sets usage, pixel thickness (CurveThickness) or a scale thickness (CurveThicknessScale) /// + /// 8.7 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public void SetCurveThicknessUsage(CurveThicknessUse usage) { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage, (int)usage); } + /// /// Gets current usage, pixel thickness (CurveThickness) or a scale thickness (CurveThicknessScale) /// + /// 8.7 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public CurveThicknessUse GetCurveThicknessUsage() { return (CurveThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage); @@ -646,6 +662,7 @@ public int CurveThickness /// /// Scale thickness for curves /// + /// 8.4 public float CurveThicknessScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.CurveThicknessScale); } @@ -766,37 +783,39 @@ enum SurfaceEdgeThicknessFlags : int AllSurfaceFixedWidth = EdgeFixedWidth | NakedEdgeFixedWidth | IsoFixedWidth } - public enum SurfaceEdgeThicknessUse : int + public enum SurfaceThicknessUse : int { ObjectWidth = 0, - Pixels = 1, + Pixels = 1 } /// /// Helper function for setting the SurfaceEdgeThicknessFlags /// /// - public SurfaceEdgeThicknessUse GetSurfaceEdgeThicknessUsage() + /// 8.6 + public SurfaceThicknessUse GetSurfaceEdgeThicknessUsage() { SurfaceEdgeThicknessFlags currentUsage = (SurfaceEdgeThicknessFlags)(GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SurfaceThicknessUsage) & (int)SurfaceEdgeThicknessFlags.EdgeFixedWidth); - if (currentUsage == SurfaceEdgeThicknessFlags.EdgeFixedWidth) return SurfaceEdgeThicknessUse.Pixels; - return SurfaceEdgeThicknessUse.ObjectWidth; + if (currentUsage == SurfaceEdgeThicknessFlags.EdgeFixedWidth) return SurfaceThicknessUse.Pixels; + return SurfaceThicknessUse.ObjectWidth; } /// /// Helper function for getting the SurfaceEdgeThicknessFlags /// /// - public void SetSurfaceEdgeThicknessUsage(SurfaceEdgeThicknessUse use) + public void SetSurfaceEdgeThicknessUsage(SurfaceThicknessUse use) { SurfaceEdgeThicknessFlags currentUsage = (SurfaceEdgeThicknessFlags)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SurfaceThicknessUsage); - if (SurfaceEdgeThicknessUse.ObjectWidth == use) + if (SurfaceThicknessUse.ObjectWidth == use) currentUsage &= ~SurfaceEdgeThicknessFlags.EdgeFixedWidth; else currentUsage |= SurfaceEdgeThicknessFlags.EdgeFixedWidth; SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SurfaceThicknessUsage, (int)currentUsage); } + /// 8.6 public enum SurfaceNakedEdgeThicknessUse : int { UseSurfaceEdgeSettings = 0, @@ -808,6 +827,7 @@ public enum SurfaceNakedEdgeThicknessUse : int /// This is a helper function that combines setting SurfaceNakeEdgeUseNormalThickness and SurfaceNakedEdgeThicknessUsageFlags settings to correspond /// to the behavor of the Settings page. /// + /// 8.6 public void SetSurfaceNakedEdgeThicknessUsage(SurfaceNakedEdgeThicknessUse use) { if (SurfaceNakedEdgeThicknessUse.UseSurfaceEdgeSettings == use) SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceNakedEdgeUseNormalEdgeThickness, true); @@ -827,6 +847,7 @@ public void SetSurfaceNakedEdgeThicknessUsage(SurfaceNakedEdgeThicknessUse use) /// This is a helper function that combines getting SurfaceNakeEdgeUseNormalThickness and SurfaceNakedEdgeThicknessUsageFlags settings to correspond /// to the behavor of the Settings page. /// + /// 8.6 public SurfaceNakedEdgeThicknessUse GetSurfaceNakedEdgeThicknessUsage() { if (GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceNakedEdgeUseNormalEdgeThickness)) @@ -838,6 +859,7 @@ public SurfaceNakedEdgeThicknessUse GetSurfaceNakedEdgeThicknessUsage() return SurfaceNakedEdgeThicknessUse.ObjectWidth; } + /// 8.6 public enum SurfaceIsoThicknessUse : int { ObjectWidth = 0, @@ -849,6 +871,7 @@ public enum SurfaceIsoThicknessUse : int /// This is a helper function that combines setting IsoThicknessUsed and SurfaceNakedEdgeThicknessUsageFlags settings to correspond /// to the behavor of the Settings page. /// + /// 8.6 public void SetSurfaceIsoThicknessUsage(SurfaceIsoThicknessUse value) { SurfaceEdgeThicknessFlags currentUsage = (SurfaceEdgeThicknessFlags)(GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SurfaceThicknessUsage) & (int)SurfaceEdgeThicknessFlags.IsoFixedWidth); @@ -865,6 +888,7 @@ public void SetSurfaceIsoThicknessUsage(SurfaceIsoThicknessUse value) /// This is a helper function that combines getting IsoThicknessUsed and SurfaceNakedEdgeThicknessUsageFlags settings to correspond /// to the behavor of the Settings page. /// + /// 8.6 public SurfaceIsoThicknessUse GetSurfaceIsoThicknessUsage() { if (GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoThicknessUsed)) @@ -881,6 +905,7 @@ public SurfaceIsoThicknessUse GetSurfaceIsoThicknessUsage() /// /// /// + /// 8.6 public void SetSurfaceIsoApplyPattern(bool u, bool v, bool w) { UnsafeNativeMethods.CDisplayPipelineAttributes_SetIsoApplyPattern(ConstPointer(), u, v, w); @@ -891,12 +916,14 @@ public void SetSurfaceIsoApplyPattern(bool u, bool v, bool w) /// Gets mode in the u direction /// Gets mode in the v direction /// Gets mode in the w direction + /// 8.6 public void GetSurfaceIsoApplyPattern(out bool u, out bool v, out bool w) { u = v = w = false; UnsafeNativeMethods.CDisplayPipelineAttributes_GetIsoApplyPattern(NonConstPointer(), ref u, ref v, ref w); } + /// 8.6 public bool SurfaceIsoShowForFlatFaces { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowFlatSurfaceIsos); } @@ -905,6 +932,7 @@ public bool SurfaceIsoShowForFlatFaces /// /// /// + /// 8.6 public bool SurfaceIsoThicknessUsed { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoThicknessUsed); } @@ -914,6 +942,7 @@ public bool SurfaceIsoThicknessUsed /// /// Turn pattern application on or off /// + /// 8.6 public bool SurfaceEdgeApplyPattern { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceEdgeApplyPattern); } @@ -923,6 +952,7 @@ public bool SurfaceEdgeApplyPattern /// /// Turn pattern application on or off /// + /// 8.6 public bool SurfaceNakedEdgeApplyPattern { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceNakedEdgeApplyPattern); } @@ -932,33 +962,38 @@ public bool SurfaceNakedEdgeApplyPattern /// /// Turn Surface Edge visibility on or off /// + /// 8.6 public bool ShowSurfaceEdge { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowEdges); } - set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowEdges, value); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowEdges, value); } } /// /// Turn Surface Naked Edge visibility on or off /// + /// 8.6 public bool ShowSurfaceNakedEdge { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowNakedEdges); } set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowNakedEdges, value); } } + /// 8.6 public enum SurfaceEdgeColorUse : int { ObjectColor = 0, IsocurveColor = 1, SingleColorForAll = 2 } + /// 8.6 public SurfaceEdgeColorUse SurfaceEdgeColorUsage { get { return (SurfaceEdgeColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorUsage); } - set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorUsage, (int)value); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorUsage, (int)value); } } + /// 8.6 public enum SurfaceNakedEdgeColorUse : int { UseSurfaceEdgeSettings = 0, @@ -967,12 +1002,14 @@ public enum SurfaceNakedEdgeColorUse : int SingleColorForAll = 3 } + /// 8.6 public SurfaceNakedEdgeColorUse SurfaceNakedEdgeColorUsage { get { return (SurfaceNakedEdgeColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeColorUsage); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeColorUsage, (int)value); } } + /// 8.6 public enum SurfaceIsoColorUse : int { ObjectColor = 0, @@ -984,6 +1021,7 @@ public enum SurfaceIsoColorUse : int /// Helper function for setting SurfaceIsoColorsUsed and SurfaceIsoSingleColor /// /// + /// 8.6 public void SetSurfaceIsoColorUsage(SurfaceIsoColorUse use) { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoColorsUsed, SurfaceIsoColorUse.SpecifiedUV == use); @@ -992,6 +1030,7 @@ public void SetSurfaceIsoColorUsage(SurfaceIsoColorUse use) /// /// Helper function for getting SurfaceIsoColorsUsed and SurfaceSingleIsoColor /// + /// 8.6 public SurfaceIsoColorUse GetSurfaceIsoColorUsage() { if (GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleIsoColor)) return SurfaceIsoColorUse.SingleColorForAll; @@ -999,103 +1038,137 @@ public SurfaceIsoColorUse GetSurfaceIsoColorUsage() return SurfaceIsoColorUse.ObjectColor; } + /// 8.6 public bool SurfaceIsoSingleColor { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleIsoColor); } - set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleIsoColor, value); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleIsoColor, value); } } + /// 8.6 public bool SurfaceIsoColorsUsed { get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoColorsUsed); } set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoColorsUsed, value); } } + /// 8.6 public Color SurfaceEdgeColor { get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.EdgeColor); } set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.EdgeColor, value); } } + /// 8.6 public Color SurfaceNakedEdgeColor { get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.NakedEdgeColor); } set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.NakedEdgeColor, value); } } + /// 8.6 public Color SurfaceIsoUVColor { get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoColor); } set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoColor, value); } } + /// 8.6 public Color SurfaceIsoUColor { get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoUColor); } set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoUColor, value); } } + /// 8.6 public Color SurfaceIsoVColor { get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoVColor); } set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.IsoVColor, value); } } + /// 8.6 + public int SurfaceEdgeColorReduction + { + get { return SurfaceEdgeColorReductionPercent; } + set { SurfaceEdgeColorReductionPercent = value; } + } + + /// 8.6 + public int SurfaceNakedAdgeColorReduction + { + get { return SurfaceNakedEdgeColorReductionPercent; } + set { SurfaceNakedEdgeColorReductionPercent = value; } + } + + /// 8.7 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public int SurfaceEdgeColorReductionPercent { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorReduction); } set { if (value < 0) value = 0; if (value > 100) value = 100; SetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorReduction, value); } } + /// 8.7 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public int SurfaceNakedEdgeColorReductionPercent { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeColorReduction); } set { if (value < 0) value = 0; if (value > 100) value = 100; SetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeColorReduction, value); } } + /// 8.6 public int SurfaceNakedEdgeThickness { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeThickness); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.NakedEdgeThickness, value); } } + /// 8.6 public int SurfaceIsoThickness { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoThickness); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoThickness, value); } } + /// 8.6 public int SurfaceIsoUThickness { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoUThickness); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoUThickness, value); } } + /// 8.6 public int SurfaceIsoVThickness { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoVThickness); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.IsoVThickness, value); } } + /// 8.6 public float SurfaceEdgeThicknessScale { - get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceEdgeThicknessScale); } - set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceEdgeThicknessScale, value); } + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceEdgeThicknessScale); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceEdgeThicknessScale, value); } } + /// 8.6 public float SurfaceNakedEdgeThicknessScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceNakedEdgeThicknessScale); } set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceNakedEdgeThicknessScale, value); } } + /// 8.6 public float SurfaceIsoThicknessUScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoUThicknessScale); } set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoUThicknessScale, value); } } + /// 8.6 public float SurfaceIsoThicknessVScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoVThicknessScale); } set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoVThicknessScale, value); } } + /// 8.7 public float SurfaceIsoThicknessWScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoWThicknessScale); } @@ -1172,9 +1245,9 @@ public Color AllMeshWiresColor } set { - bool single_color = (value!=Color.Empty); + bool single_color = (value != Color.Empty); m_parent.SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SingleMeshWireColor, single_color); - if( single_color ) + if (single_color) m_parent.SetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshWireColor, value); } } @@ -1261,6 +1334,7 @@ public bool ShowLights set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowLights, value); } } + /// 8.4 public enum LightingSchema { None = 0, @@ -1271,6 +1345,7 @@ public enum LightingSchema } //ELightingScheme m_eLightingScheme; + /// 8.4 public LightingSchema LightingScheme { get @@ -1306,6 +1381,14 @@ public Color ShadowColor set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.ShadowColor, value); } } + /// 8.6 + [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] + public int ColorReductionPct + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorReduction); } + set { if (value < 0) value = 0; if (value > 100) value = 100; SetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorReduction, value); } + } + //ON_3dVector m_ShadowBias; //double m_fShadowBlur; /// Cast shadows. @@ -1683,6 +1766,7 @@ public StereoContext StereoContext /// /// Get or set the front material shine (0 to Rhino.DocObjects.MaxShine). You must call DisplayModeDescription.UpdateDisplayMode() to commit this change. /// + /// 8.4 public double FrontMaterialShine { get @@ -1699,6 +1783,7 @@ public double FrontMaterialShine /// /// Get or set the back material shine (0 to Rhino.DocObjects.MaxShine). You must call DisplayModeDescription.UpdateDisplayMode() to commit this change. /// + /// 8.4 public double BackMaterialShine { get @@ -1715,6 +1800,7 @@ public double BackMaterialShine /// /// Get or set the front material transparency (0 to 100). You must call DisplayModeDescription.UpdateDisplayMode() to commit this change. /// + /// 8.4 public double FrontMaterialTransparency { get @@ -1731,6 +1817,7 @@ public double FrontMaterialTransparency /// /// Get or set the back material transparency (0 to 100). You must call DisplayModeDescription.UpdateDisplayMode() to commit this change. /// + /// 8.4 public double BackMaterialTransparency { get @@ -1745,6 +1832,7 @@ public double BackMaterialTransparency } } + /// 8.8 public Color BackMaterialDiffuseColor { get @@ -1757,6 +1845,7 @@ public Color BackMaterialDiffuseColor } } + /// 8.8 public bool CullBackfaces { get @@ -1768,7 +1857,1097 @@ public bool CullBackfaces SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CullBackfaces, value); } } + /// + /// Color reduction percentage + /// + public int SubDSmoothInteriorColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDSmoothInteriorColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDSmoothInteriorColorReduction, value); } + } + /// + /// Color reduction percentage + /// + public int SubDCreaseInteriorColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDCreaseInteriorColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDCreaseInteriorColorReduction, value); } + } + /// + /// Color reduction percentage + /// + public int SubDNonManifoldColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDNonManifoldColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDNonManifoldColorReduction, value); } + } + /// + /// Color reduction percentage + /// + public int SubDBoundaryColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDBoundaryColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDBoundaryColorReduction, value); } + } + /// + /// SubD edge color use + /// + public enum SubDEdgeColorUse : int + { + ObjectColor = 0, + SingleColorForAll = 1 + } + /// + /// Edge color usage + /// + public SubDEdgeColorUse SubDSmoothInteriorEdgeColorUsage + { + get { return (SubDEdgeColorUse)(UnsafeNativeMethods.DisplayAttributesInt.SubDSmoothInteriorEdgeColorUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDSmoothInteriorEdgeColorUsage, (int)value); } + } + /// + /// Edge color usage + /// + public SubDEdgeColorUse SubDCreaseInteriorEdgeColorUsage + { + get { return (SubDEdgeColorUse)(UnsafeNativeMethods.DisplayAttributesInt.SubDCreaseInteriorEdgeColorUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDCreaseInteriorEdgeColorUsage, (int)value); } + } + /// + /// Edge color usage + /// + public SubDEdgeColorUse SubDNonManifoldEdgeColorUsage + { + get { return (SubDEdgeColorUse)(UnsafeNativeMethods.DisplayAttributesInt.SubDNonManifoldEdgeColorUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDNonManifoldEdgeColorUsage, (int)value); } + } + /// + /// Edge color usage + /// + public SubDEdgeColorUse SubDBoundaryEdgeColorUsage + { + get { return (SubDEdgeColorUse)(UnsafeNativeMethods.DisplayAttributesInt.SubDBoundaryEdgeColorUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDBoundaryEdgeColorUsage, (int)value); } + } + /// + /// SubD replection plane color use + /// + public enum SubDReflectionPlaneColorUse : int + { + ObjectColor = 0, + CustomColor = 1, + SingleColorForAll = 2 + } + /// + /// SubD replection plane color use + /// + public SubDReflectionPlaneColorUse SubDReflectionPlaneColorUsage + { + get { return (SubDReflectionPlaneColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDReflectionPlaneColorUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDReflectionPlaneColorUsage, (int)value); } + } + /// + /// SubD replection plane color reduction percentage + /// + public int SubDReflectionPlaneColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDReflectionPlaneColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.SubDReflectionPlaneColorReduction, value); } + } + /// + /// Mesh edge width in pixels + /// + public int MeshEdgeThickness + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshEdgeThickness); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshEdgeThickness, value); } + } + /// + /// Naked mesh edge width in pixels.} + /// + public int MeshNakedEdgeThickness + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNakedEdgeThickness); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNakedEdgeThickness, value); } + } + /// + /// Non-manifold mesh edge width in pixels + /// + public int MeshNonmanifoldEdgeThickness + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNonmanifoldEdgeThickness); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNonmanifoldEdgeThickness, value); } + } + /// + /// Mesh vertex size in pixels + /// + public int MeshVertexSize + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshVertexSize); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshVertexSize, value); } + } + /// + /// The darken percentage of the color + /// + public int MeshEdgeColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshEdgeColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshEdgeColorReduction, value); } + } + /// + /// The darken percentage of the color + /// + public int MeshNakedEdgeColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNakedEdgeColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNakedEdgeColorReduction, value); } + } + /// + /// The darken percentage of the color + /// + public int MeshNonmanifoldEdgeColorReduction + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNonmanifoldEdgeColorReduction); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.MeshNonmanifoldEdgeColorReduction, value); } + } + /// + /// Edge thickness scale + /// + public float SubDSmoothInteriorThicknessScale + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDSmoothInteriorThicknessScale); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDSmoothInteriorThicknessScale, value); } + } + /// + /// Edge thickness scale + /// + public float SubDCreaseInteriorThicknessScale + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDCreaseInteriorThicknessScale); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDCreaseInteriorThicknessScale, value); } + } + /// + /// Edge thickness scale + /// + public float SubDNonManifoldThicknessScale + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDNonManifoldThicknessScale); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDNonManifoldThicknessScale, value); } + } + /// + /// Edge thickness scale + /// + public float SubDBoundaryThicknessScale + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDBoundaryThicknessScale); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDBoundaryThicknessScale, value); } + } + /// + /// Edge thickness (pixels). + /// + // This isn't an int for some reason, even though the UI acts like it is and it would be more consistent + public float SubDSmoothInteriorEdgeThickness + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDSmoothInteriorEdgeThickness); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDSmoothInteriorEdgeThickness, value); } + } + /// + /// Edge thickness (pixels). + /// + // This isn't an int for some reason, even though the UI acts like it is and it would be more consistent + public float SubDCreaseInteriorEdgeThickness + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDCreaseInteriorEdgeThickness); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDCreaseInteriorEdgeThickness, value); } + } + /// + /// Edge thickness (pixels). + /// + // This isn't an int for some reason, even though the UI acts like it is and it would be more consistent + public float SubDNonManifoldEdgeThickness + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDNonManifoldEdgeThickness); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDNonManifoldEdgeThickness, value); } + } + /// + /// Edge thickness (pixels). + /// + // This isn't an int for some reason, even though the UI acts like it is and it would be more consistent + public float SubDBoundaryEdgeThickness + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDBoundaryEdgeThickness); } + set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SubDBoundaryEdgeThickness, value); } + } + + public enum SubDThicknessUse : int + { + ObjectWidth = 0, + Pixels = 1 + } + + /// + /// Thickness usage, pixel thickness or a scale thickness + /// + public SubDThicknessUse SubDThicknessUsage + { + get { return (SubDThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDThicknessUsage, (int)value); } + } + public SubDThicknessUse SubDSmoothInteriorThicknessUsage + { + get { return (SubDThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDSmoothInteriorThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDSmoothInteriorThicknessUsage, (int)value); } + } + public SubDThicknessUse SubDCreaseInteriorThicknessUsage + { + get { return (SubDThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDCreaseInteriorThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDCreaseInteriorThicknessUsage, (int)value); } + } + public SubDThicknessUse SubDNonManifoldThicknessUsage + { + get { return (SubDThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDNonManifoldThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDNonManifoldThicknessUsage, (int)value); } + } + public SubDThicknessUse SubDBoundaryThicknessUsage + { + get { return (SubDThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDBoundaryThicknessUsage); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SubDBoundaryThicknessUsage, (int)value); } + } + /// + /// Apply pattern to the edge + /// + public bool SubDSmoothInteriorApplyPattern + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDSmoothInteriorApplyPattern); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDSmoothInteriorApplyPattern, value); } + } + /// + /// Apply pattern to the edge + /// + public bool SubDCreaseInteriorApplyPattern + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDCreaseInteriorApplyPattern); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDCreaseInteriorApplyPattern, value); } + } + /// + /// Apply pattern to the edge + /// + public bool SubDNonManifoldApplyPattern + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDNonManifoldApplyPattern); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDNonManifoldApplyPattern, value); } + } + /// + /// Apply pattern to the edge + /// + public bool SubDBoundaryApplyPattern + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDBoundaryApplyPattern); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDBoundaryApplyPattern, value); } + } + /// + /// Apply Turnh on or off the reflection plane axis line + /// + public bool SubDReflectionPlaneAxisLineOn + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDReflectionPlaneAxisLineOn); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDReflectionPlaneAxisLineOn, value); } + } + /// + /// Edge color + /// + public Color SubDSmoothInteriorEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDSmoothInteriorEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDSmoothInteriorEdgeColor, value); } + } + /// + /// Edge color + /// + public Color SubDCreaseInteriorEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDCreaseInteriorEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDCreaseInteriorEdgeColor, value); } + } + /// + /// Edge color + /// + public Color SubDNonManifoldEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDNonManifoldEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDNonManifoldEdgeColor, value); } + } + /// + /// Edge color + /// + public Color SubDBoundaryEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDBoundaryEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDBoundaryEdgeColor, value); } + } + /// + /// Reflection axis line color + /// + public Color SubDReflectionAxisLineColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDReflectionAxisLineColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDReflectionAxisLineColor, value); } + } + /// + /// Reflection plane color + /// + public Color SubDReflectionPlaneColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDReflectionPlaneColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.SubDReflectionPlaneColor, value); } + } + /// + /// Sets the mesh edge color + /// + public Color MeshEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshEdgeColor, value); } + } + /// + /// Sets the naked edge color + /// + public Color MeshNakedEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshNakedEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshNakedEdgeColor, value); } + } + /// + /// Sets the nonmanifold edge color + /// + public Color MeshNonmanifoldEdgeColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshNonmanifoldEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.MeshNonmanifoldEdgeColor, value); } + } + + /// + /// Height above the world XY plane in model units + /// + public double CustomGroundPlaneAltitude + { + get { return GetDouble(UnsafeNativeMethods.DisplayAttributesDouble.CustomGroundPlaneAltitude); } + set { SetDouble(UnsafeNativeMethods.DisplayAttributesDouble.CustomGroundPlaneAltitude, value); } + } + /// + /// Turn the custom ground plane on or off + /// + public bool CustomGroundPlaneOn + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneOn); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneOn, value); } + } + /// + /// Makes the ground plane transparent, but allows shadows to still be cast on it. + /// + public bool CustomGroundPlaneShadowOnly + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneShadowOnly); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneShadowOnly, value); } + } + + /// + /// Turns on auto-elevation that moves Ground Plane to the lowest point of the objects in the model. + /// + public bool CustomGroundPlaneAutomaticAltitude + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneAutomaticAltitude); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CustomGroundPlaneAutomaticAltitude, value); } + } + /// + /// Set visibility of SubD smooth edges. + /// + public bool ShowSubDEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDEdges, value); } + } + /// + /// Set visibility of SubD creased edges. + /// + public bool ShowSubDCreases + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDCreases); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDCreases, value); } + } + /// + /// Set visibility of SubD naked edges. + /// + public bool ShowSubDBoundary + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDBoundary); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDBoundary, value); } + } + /// + /// Turn on/off color differentiation of SubD symmetry children. + /// + public bool ShowSubDNonmanifoldEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDNonmanifoldEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowSubDNonmanifoldEdges, value); } + } + public bool ShowSubDReflectionPlanePreview + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDReflectedPreview); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SubDReflectedPreview, value); } + } + /// + /// Display mesh edges on/off + /// + public bool ShowMeshEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshEdges, value); } + } + /// + /// Display mesh naked edges on/off + /// + public bool ShowMeshNakedEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshNakedEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshNakedEdges, value); } + } + + /// + /// Display mesh manifold edges on/off + /// + public bool ShowMeshNonmanifoldEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshNonmanifoldEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowMeshNonmanifoldEdges, value); } + } + /// + /// Draw lights using light color + /// + public bool UseLightColor + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.UseLightColor); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.UseLightColor, value); } + } + /// + /// When a clipping plane intersects a 3-D object and the section is closed, the section is filled. + /// + public bool ShowClippingFills + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowXSurface); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowXSurface, value); } + } + /// + /// Shows the edges between the clipping plane and clipped objects. + /// + public bool ShowClippingEdges + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowXEdges); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowXEdges, value); } + } + /// + /// Shades the selected clipping plane. + /// + public bool ClippingShadeSelectedPlane + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowCP); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingShowCP, value); } + } + /// + /// Clips the highlight wires. Shaded selections always clip. + /// + public bool ClipSelectionHighlight + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingClipSelected); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ClippingClipSelected, value); } + } + + /// + /// + /// + public enum ClippingPlaneFillColorUse : int + { + /// + /// Follows how the object displays in the viewport. + /// + ViewportColor = 0, + /// + /// Uses the object's render material. + /// + RenderMaterialColor = 1, + /// + /// Uses the clipping plane's color or layer color property. + /// + PlaneMaterialColor = 2, + /// + /// Solid color + /// + SolidColor = 3 + } + + /// + /// Specifies how the color for the clipping plane object fill is determined. + /// + public ClippingPlaneFillColorUse ClippingPlaneFillColorUsage + { + get { return (ClippingPlaneFillColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingSurfaceUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingSurfaceUsage, (int)value); } + } + /// + /// Clipping plane fill color + /// + public Color ClippingFillColor + { + get { return (Color)GetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingSurfaceColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingSurfaceColor, value); } + } + + /// + /// + /// + public enum ClippingEdgeColorUse : int + { + /// + /// Uses the clipping plane's color (object or layer). + /// + PlaneColor = 0, + /// + /// Solid color + /// + SolidColor = 1, + /// + /// Uses the object's color (object or layer). + /// + ObjectColor = 2 + } + /// + /// Specifies how the color for the Edges is determined + /// + public ClippingEdgeColorUse ClippingEdgeColorUsage + { + get { return (ClippingEdgeColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingEdgesUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingEdgesUsage, (int)value); } + } + /// + /// Clipping edge color + /// + public Color ClippingEdgeColor + { + get { return (Color)GetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingEdgeColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingEdgeColor, value); } + } + + /// + /// + /// + public enum ClippingShadeColorUse : int + { + /// + /// Uses the clipping plane's color (object or layer). + /// + PlaneColor = 0, + /// + /// Uses the plane's render material (object or layer). + /// + PlaneMaterialColor = 1, + /// + /// Solid Color + /// + SolidColor = 2 + } + /// + /// Specifies how to shade the clipping plane + /// + public ClippingShadeColorUse ClippingShadeColorUsage + { + get { return (ClippingShadeColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingCPUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingCPUsage, (int)value); } + } + /// + /// Clipping plane solid color + /// + public Color ClippingShadeColor + { + get { return (Color)GetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingCPColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.ClippingCPColor, value); } + } + /// + /// Edge thickness in pixels. + /// + public int ClippingEdgeThickness + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingEdgeThickness); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingEdgeThickness, value); } + } + /// + /// Specifies the clipping plane transparency percentage. + /// + public int ClippingShadeTransparency + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingCPTrans); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.ClippingCPTrans, value); } + } + /// + /// When enabled, the appearances of clipping fills and edges are based on objects' section style properties. + /// + public bool UseSectionStyles + { + get { return (1 == GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ClipSectionUsage)); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ClipSectionUsage, value ? 1 : 0); } + } + + /// + /// The width of the control polygon lines in pixels. + /// + public int ControlPolygonWireThickness + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.CPWireThickness); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.CPWireThickness, value); } + } + /// + /// PointStyle for the control polygon. Supported values are ControlPoint, RoundControlPoint, VariableDot, and RoundDot + /// + public PointStyle ControlPolygonStyle + { + get { return (PointStyle)GetInt(UnsafeNativeMethods.DisplayAttributesInt.CVStyle); } + set + { + if (value != PointStyle.RoundControlPoint && value != PointStyle.VariableDot && value != PointStyle.RoundDot) + value = PointStyle.ControlPoint; + + SetInt(UnsafeNativeMethods.DisplayAttributesInt.CVStyle, (int)value); + } + } + /// + /// The control point size in pixels. + /// + public int ControlPolygonGripSize + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.CVSize); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.CVSize, value); } + } + + /// + /// LockedObjectTransparency. + /// + public int LockedObjectTransparency + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.LockedTrans); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.LockedTrans, value); } + } + + public enum LockedObjectUse : int + { + /// + /// Uses the object's specified attributes. + /// + UseObjectAttributes = 0, + /// + /// Use specified lock color + /// + SpecifyColor = 1, + /// + /// Use settings specified in Appearance: Colors Options. + /// + UseAppSettings = 2 + } + + /// + /// Set asource of display attributes for locked objects + /// + public LockedObjectUse LockedObjectUsage + { + get { return (LockedObjectUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.LockedUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.LockedUsage, (int)value); } + } + + /// + /// + /// + public enum DynamicDisplayUse + { + /// + /// Use system default settings. + /// + UseAppSettings = 0, + /// + /// Reduces the display of objects to their bounding boxes. This can speed up the display on large models. + /// + DisplayObjectBoundingBox = 1 + } + /// + /// Sets the appearance of objects in the display + /// + public DynamicDisplayUse DynamicDisplayUsage + { + get { return (DynamicDisplayUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.BBoxMode); } + set { SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.BBoxMode, (int)value); } + } + /// + /// Shades entire object with highlight color. + /// + public bool HighlightSurfaces + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.HighlightSurfaces); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.HighlightSurfaces, value); } + } + /// + /// Use dotted / solid lines + /// + public bool ControlPolygonUseSolidLines + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPSolidLines); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPSolidLines, value); } + } + /// + /// Specifies a color for the control polygon. + /// + /// true = Use a specified color for all control polygons. + /// false = Use the color specified in the object's Properties. + public bool ControlPolygonUseFixedSingleColor + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPSingleColor); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPSingleColor, value); } + } + /// + /// Shows the control points while the control polygon is displayed. + /// + public bool ControlPolygonShowPoints + { + get { return !GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHidePoints); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHidePoints, !value); } + } + /// + /// Shows the object while the control polygon is displayed. + /// + public bool ControlPolygonShowSurface + { + get { return !GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHideSurface); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHideSurface, !value); } + } + /// + /// Shows the control polygon and only shows the control points. + /// + public bool ControlPolygonShow + { + get { return !GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHidden); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHidden, !value); } + } + /// + /// Highlights the segments of the control polygon on either side of the control points. + /// + public bool ControlPolygonHighlight + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHighlight); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.CPHighlight, value); } + } + /// + /// Set locked appearance + /// + /// true = Locked objects appear transparent + /// false = Locked objects appear solid + public bool GhostLockedObjects + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.GhostLockedObjects); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.GhostLockedObjects, value); } + } + /// + /// Applies the settings for locked objects to locked layers. + /// + public bool LayersFollowLockUsage + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.LayersFollowLockUsage); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.LayersFollowLockUsage, value); } + } + /// + /// Control polygon color + /// + public Color ControlPolygonColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.CPColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.CPColor, value); } + } + /// + /// Locked Object Color + /// + public Color LockedColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.LockedColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.LockedColor, value); } + } + + /// + /// Enable shadows + /// + public bool ShadowsOn + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.Shadows); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.Shadows, value); } + } + /// + /// Shadow intensity (percentage 0-100) + /// + public int ShadowIntensity + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowIntensity); } + set + { + if (value < 0) value = 0; + else if (value > 100) value = 100; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowIntensity, value); + } + } + /// + /// Value from 1 to 16384 indicating how much memory is to be allocated. Actual memory use + /// is ShadowMemoryUsage*ShadowMemoryUsage*4. + /// + public int ShadowMemoryUsage + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMemoryUsage); } + set + { + if (value < 1) value = 1; + else if (value > 16384) value = 16384; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMemoryUsage, value); + } + } + /// + /// Skylight shadow quality, from 0 (lowest) to 8 (highest) + /// + public int SkylightShadowQuality + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.SkylightQuality); } + set + { + if (value < 0) value = 0; + else if (value > 8) value = 8; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.SkylightQuality, value); + } + } + + // might expose this stuff in the future + private const int CubeShadows = 50; + private const int DrmShadows = 100; + private enum ShadowMapType : uint + { + None = 0, + Normal = 1, + Sampled = 2, + PCF = 3, + Dithered = 4, + + GI = 5, + + NormalCube = Normal + CubeShadows, + SampledCube = Sampled + CubeShadows, + PCFCube = PCF + CubeShadows, + SMDitheredCube = Dithered + CubeShadows, + + Force32bit = 0xFFFFFFFF + } + /// + /// Soft edge quality, from 0 (none/faster) to 12 (softer/slower) + /// + public int ShadowSoftEdgeQuality + { + get + { + if (GetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMapType) == (int)ShadowMapType.Normal) + return 0; + else + { + return GetInt(UnsafeNativeMethods.DisplayAttributesInt.NumSamples); + } + } + set + { + if (value < 0) value = 0; + if (value > 12) value = 12; + + if (value == 0) + { + SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMapType, (int)ShadowMapType.Normal); + SetInt(UnsafeNativeMethods.DisplayAttributesInt.NumSamples, 0); + } + else + { + SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMapType, (int)ShadowMapType.Sampled); + SetInt(UnsafeNativeMethods.DisplayAttributesInt.NumSamples, value); + } + } + } + /// + /// Set blurring from 0 (no blurring) to 16 (maximum blurring) + /// + public double ShadowEdgeBlur + { + get { return GetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBlur); } + set + { + if (value < 0.0f) value = 0.0f; + if (value > 16.0f) value = 16.0f; + SetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBlur, value); + } + } + /// + /// ShadowBiasX (Self shadowing artifacts) from 0 (dirty) to 50 (cleaner). + /// + public double ShadowBiasX + { + get { return GetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBiasX); } + set + { + if (value < 0.0) value = 0.0; + if (value > 50.0) value = 50.0; + SetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBiasX, value); } + } + /// + /// Transparency tolerance from 0 (never cast shadows) to 100 (always case shadows) + /// + public int ShadowTransparencyTolerance + { + get { return (int)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.TransparencyTolerance); } + set + { + if (value < 0) value = 0; + if (value > 100) value = 100; + SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.TransparencyTolerance, value); + } + } + /// + /// Camera-based shadow clipping radius + /// + public float ShadowClippingRadius + { + get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.ShadowClippingRadius); } + set + { + int current = GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage); + if (value == 0.0) + current &= 0xF0; + else + current |= 0x01; + + SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.ShadowClippingRadius, value); + } + } + + /// + /// If true, shadows ignore user-defined clipping planes + /// + public bool ShadowsIgnoreUserDefinedClippingPlanes + { + get { return (0 != (0x10 & GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage))); } + set + { + int current = GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage); + if (value) current |= 0x10; + if (!value) current &= ~0x10; + SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage, current); + } + } + + /// + /// Size of axes as a percentage of the grid extents. + /// + public int AxesSizePercentage + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.AxesPercentage); } + set + { + if (value < 0) value = 0; + else if (value > 100) value = 100; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.AxesPercentage, value); + } + } + + /// + /// Transparency of the grid, percentage (0-100) + /// + public int GridTransparency + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.GridTrans); } + set + { + if (value < 0) value = 0; + else if (value > 100) value = 100; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.GridTrans, value); + } + } + + /// + /// Transparency of the grid plane, percentage (0-100) + /// + public int GridPlaneTransparency + { + get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.GridPlaneTrans); } + set + { + if (value < 0) value = 0; + else if (value > 100) value = 100; + SetInt(UnsafeNativeMethods.DisplayAttributesInt.GridPlaneTrans, value); + } + } + public enum GridPlaneVisibilityMode : int + { + /// + /// Show only when grid is on + /// + ShowOnlyIfGridVisible = 0, + /// + /// Show always + /// + AlwaysShow = 1 + } + /// + /// Set when to show the grid plane + /// + public GridPlaneVisibilityMode GridPlaneVisibility + { + get { return (GridPlaneVisibilityMode)GetInt(UnsafeNativeMethods.DisplayAttributesInt.PlaneVisibility); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.PlaneVisibility, (int)value); } + } + + public enum WorldAxesIconColorUse : int + { + /// + /// Use default setting + /// + UseApplicationSettings = 0, + /// + /// Set colors for grid axes in Appearance: Colors Options + /// + SameAsGridAxesColors = 1, + /// + /// Use specified custom colors + /// + Custom = 2 + } + public WorldAxesIconColorUse WorldAxesIconColorUsage + { + get { return (WorldAxesIconColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.WorldAxesColor); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.WorldAxesColor, (int)value); } + } + + /// + /// If true, use the grid thin line color in App settings + /// + public bool PlaneUsesGridColor + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PlaneUsesGridColor); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PlaneUsesGridColor, value); } + } + + /// + /// The color of the grid plane + /// + public Color GridPlaneColor + { + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.GridPlaneColor); } + set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.GridPlaneColor, value); } + } + + } +} - } -} #endif diff --git a/src/dotnet/rhino/rhinosdkdoc.cs b/src/dotnet/rhino/rhinosdkdoc.cs index bac4a9898..b322e7c04 100644 --- a/src/dotnet/rhino/rhinosdkdoc.cs +++ b/src/dotnet/rhino/rhinosdkdoc.cs @@ -16,6 +16,7 @@ using Rhino.FileIO; using System.Diagnostics; using Rhino.Render.CustomRenderMeshes; +using Rhino.Runtime; namespace Rhino.Commands { @@ -335,14 +336,29 @@ internal static void ActiveDocTolerances(out double tolerance, out double angleT /// 6.0 public static RhinoDoc Open(string filePath, out bool wasAlreadyOpen) { - wasAlreadyOpen = (null != FromFilePath(filePath)); - if (string.IsNullOrWhiteSpace(filePath)) - return null; - if (!System.IO.File.Exists(filePath)) + // look for an already opened document + RhinoDoc openDoc = FromFilePath(filePath); + wasAlreadyOpen = (null != openDoc); + + // the file may have been removed, but if it was + // already open let's return the opened file + if (!wasAlreadyOpen && !System.IO.File.Exists(filePath)) return null; + + // assign the doc if it was already open + RhinoDoc doc; + if (wasAlreadyOpen) + { + doc = openDoc; + } + else + { + // only open the document if not yet opened, otherwise + // active doc serial# will be out of sync, see RH-82580 if (!UnsafeNativeMethods.CRhinoFileMenu_Open(filePath)) return null; - var doc = FromFilePath(filePath); + doc = FromFilePath(filePath); + } return doc; } @@ -372,7 +388,8 @@ public static RhinoDoc FromFilePath(string filePath) [Obsolete("OpenFile is obsolete, use Open instead")] public static bool OpenFile(string path) { - return UnsafeNativeMethods.CRhinoFileMenu_Open(path); + RhinoDoc unused = Open(path, out _); + return null != unused; } /// 5.0 @@ -1134,6 +1151,7 @@ public string Notes set { UnsafeNativeMethods.CRhinoDoc_GetSetString(RuntimeSerialNumber, IDX_NOTES, true, value, IntPtr.Zero); } } + /// 8.6 public bool NotesLocked { get { return GetBool(UnsafeNativeMethods.DocumentStatusBool.NotesLocked); } @@ -1472,6 +1490,21 @@ public bool SetCustomUnitSystem(bool modelUnits, string customUnitName, double m return UnsafeNativeMethods.CRhinoDocProperties_SetCustomUnitSystem(RuntimeSerialNumber, modelUnits, customUnitName, metersPerCustomUnit, scale); } + public ConstructionPlaneGridDefaults GetGridDefaults() + { + IntPtr ptrGridDefaults = UnsafeNativeMethods.CRhinoDocProperties_GetGridDefaults(RuntimeSerialNumber); + return ConstructionPlaneGridDefaults.FromConstPointer(ptrGridDefaults); + } + + public void SetGridDefaults(ConstructionPlaneGridDefaults defaults) + { + if (defaults == null) + return; + IntPtr ptrGridDefaults = UnsafeNativeMethods.ON_3dmConstructionPlaneGridDefaults_New(); + defaults.SetupNativePointer(ptrGridDefaults); + UnsafeNativeMethods.CRhinoDocProperties_SetGridDefaults(RuntimeSerialNumber, ptrGridDefaults); + UnsafeNativeMethods.ON_3dmConstructionPlaneGridDefaults_Delete(ptrGridDefaults); + } #endregion /// @@ -2678,18 +2711,22 @@ public int InCommand(bool bIgnoreScriptRunnerCommands) private static DocumentCallback g_on_new_document_callback; private static DocumentCallback g_on_set_active_document_callback; private static DocumentCallback g_on_document_properties_changed; + [MonoPInvokeCallback(typeof(DocumentCallback))] private static void OnCloseDocument(uint docSerialNumber) { m_close_document?.SafeInvoke(null, new DocumentEventArgs(docSerialNumber)); } + [MonoPInvokeCallback(typeof(DocumentCallback))] private static void OnNewDocument(uint docSerialNumber) { m_new_document?.SafeInvoke(null, new DocumentEventArgs(docSerialNumber)); } + [MonoPInvokeCallback(typeof(DocumentCallback))] private static void OnSetActiveDocument(uint docSerialNumber) { g_set_active_document?.SafeInvoke(null, new DocumentEventArgs(docSerialNumber)); } + [MonoPInvokeCallback(typeof(DocumentCallback))] private static void OnDocumentPropertiesChanged(uint docSerialNumber) { m_document_properties_changed?.SafeInvoke(null, new DocumentEventArgs(docSerialNumber)); @@ -2698,29 +2735,35 @@ private static void OnDocumentPropertiesChanged(uint docSerialNumber) // https://mcneel.myjetbrains.com/youtrack/issue/RH-68860 internal delegate void UnitsChangedWithScalingCallback(uint docSerialNumber, double scale); private static UnitsChangedWithScalingCallback g_on_units_changed_with_scaling_callback; + [MonoPInvokeCallback(typeof(UnitsChangedWithScalingCallback))] private static void OnUnitChangedWithScaling(uint docSerialNumber, double scale) { m_units_changed_with_scaling?.SafeInvoke(null, new UnitsChangedWithScalingEventArgs(docSerialNumber, scale)); } internal delegate void DocumentIoCallback(uint docSerialNumber, IntPtr pointerToWString, int b1, int b2); + [MonoPInvokeCallback(typeof(DocumentIoCallback))] private static void OnBeginOpenDocument(uint docSerialNumber, IntPtr pointerToWString, int bMerge, int bReference) { m_begin_open_document?.SafeInvoke(null, new DocumentOpenEventArgs(docSerialNumber, pointerToWString, bMerge != 0, bReference != 0)); } + [MonoPInvokeCallback(typeof(DocumentIoCallback))] private static void OnEndOpenDocument(uint docSerialNumber, IntPtr pointerToWString, int bMerge, int bReference) { m_end_open_document?.SafeInvoke(null, new DocumentOpenEventArgs(docSerialNumber, pointerToWString, bMerge != 0, bReference != 0)); } + [MonoPInvokeCallback(typeof(DocumentIoCallback))] private static void OnEndOpenDocumentInitialiViewUpdate(uint docSerialNumber, IntPtr pointerToWString, int bMerge, int bReference) { m_after_post_read_view_update_document?.SafeInvoke(null, new DocumentOpenEventArgs(docSerialNumber, pointerToWString, bMerge != 0, bReference != 0)); } + [MonoPInvokeCallback(typeof(DocumentIoCallback))] private static void OnBeginSaveDocument(uint docSerialNumber, IntPtr pointerToWString, int bExportSelected, int bUnused) { m_begin_save_document?.SafeInvoke(null, new DocumentSaveEventArgs(docSerialNumber, pointerToWString, bExportSelected != 0)); } + [MonoPInvokeCallback(typeof(DocumentIoCallback))] private static void OnEndSaveDocument(uint docSerialNumber, IntPtr pointerToWString, int bExportSelected, int bUnused) { m_end_save_document?.SafeInvoke(null, new DocumentSaveEventArgs(docSerialNumber, pointerToWString, bExportSelected != 0)); @@ -2965,6 +3008,7 @@ public static event EventHandler UserStringChanged private static event EventHandler _userStringChangedEvent; internal delegate void UserStringChangedCallback(uint docRuntimeSerialNumber, [MarshalAs(UnmanagedType.LPWStr)] string key); private static UserStringChangedCallback _userStringChangedCallback = null; + [MonoPInvokeCallback(typeof(UserStringChangedCallback))] private static void OnUserStringChanged(uint docRuntimeSerialNumber, [MarshalAs(UnmanagedType.LPWStr)] string key) { var doc = RhinoDoc.FromRuntimeSerialNumber(docRuntimeSerialNumber); @@ -3197,6 +3241,7 @@ public static event EventHandler EndSaveDocument private static RhinoObjectCallback g_on_replace_object; private static RhinoObjectCallback g_on_undelete_object; private static RhinoObjectCallback g_on_purge_object; + [MonoPInvokeCallback(typeof(RhinoObjectCallback))] private static void OnAddObject(uint docSerialNumber, IntPtr pObject, IntPtr pObject2) { m_add_object?.SafeInvoke(null, new DocObjects.RhinoObjectEventArgs(docSerialNumber, pObject)); @@ -3236,6 +3281,7 @@ public static event EventHandler AddRhinoObject } } + [MonoPInvokeCallback(typeof(RhinoObjectCallback))] private static void OnDeleteObject(uint docSerialNumber, IntPtr pObject, IntPtr pObject2) { if (m_delete_object != null) @@ -3282,6 +3328,7 @@ public static event EventHandler DeleteRhinoObj } } + [MonoPInvokeCallback(typeof(RhinoObjectCallback))] private static void OnReplaceObject(uint docSerialNumber, IntPtr pOldObject, IntPtr pNewObject) { m_replace_object?.SafeInvoke(null, new DocObjects.RhinoReplaceObjectEventArgs(docSerialNumber, pOldObject, pNewObject)); @@ -3329,6 +3376,7 @@ public static event EventHandler Replace } } + [MonoPInvokeCallback(typeof(RhinoObjectCallback))] private static void OnUndeleteObject(uint docSerialNumber, IntPtr pObject, IntPtr pObject2) { m_undelete_object?.SafeInvoke(null, new DocObjects.RhinoObjectEventArgs(docSerialNumber, pObject)); @@ -3367,6 +3415,7 @@ public static event EventHandler UndeleteRhinoO } } + [MonoPInvokeCallback(typeof(RhinoObjectCallback))] private static void OnPurgeObject(uint docSerialNumber, IntPtr pObject, IntPtr pObject2) { m_purge_object?.SafeInvoke(null, new DocObjects.RhinoObjectEventArgs(docSerialNumber, pObject)); @@ -3411,6 +3460,7 @@ public static event EventHandler PurgeRhinoObje private static RhinoObjectSelectionCallback g_on_select_rhino_object_callback; + [MonoPInvokeCallback(typeof(RhinoObjectSelectionCallback))] private static void OnSelectObject(uint docSerialNumber, int bSelect, IntPtr pObject, IntPtr pObjects) { if (m_select_objects != null && bSelect == 1) @@ -3498,6 +3548,7 @@ public static event EventHandler Desel internal delegate void RhinoDeselectAllObjectsCallback(uint docSerialNumber, int objectCount); private static RhinoDeselectAllObjectsCallback g_on_deselect_all_rhino_objects_callback; + [MonoPInvokeCallback(typeof(RhinoDeselectAllObjectsCallback))] private static void OnDeselectAllObjects(uint docSerialNumber, int count) { m_deselect_allobjects?.SafeInvoke(null, new DocObjects.RhinoDeselectAllObjectsEventArgs(docSerialNumber, count)); @@ -3543,6 +3594,7 @@ public static event EventHandler De internal delegate void RhinoModifyObjectAttributesCallback(uint docSerialNumber, IntPtr pRhinoObject, IntPtr pConstRhinoObjectAttributes); private static RhinoModifyObjectAttributesCallback g_on_modify_object_attributes_callback; + [MonoPInvokeCallback(typeof(RhinoModifyObjectAttributesCallback))] private static void OnModifyObjectAttributes(uint docSerialNumber, IntPtr pRhinoObject, IntPtr pConstRhinoObjectAttributes) { m_modify_object_attributes?.SafeInvoke(null, new DocObjects.RhinoModifyObjectAttributesEventArgs(docSerialNumber, pRhinoObject, pConstRhinoObjectAttributes)); @@ -3586,6 +3638,7 @@ public static event EventHandler Befo #region Layer table event private static RhinoTableCallback g_on_layer_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnLayerTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_layer_table_event?.SafeInvoke(null, new LayerTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -3684,6 +3738,7 @@ public static event EventHandler LayerTableEvent #region Linetype table event private static RhinoTableCallback g_on_linetype_table_event_callback; private static GCHandle g_linetype_callback_gchandle; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnLinetypeTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_linetype_table_event?.SafeInvoke(null, new LinetypeTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -3734,6 +3789,7 @@ public static event EventHandler LinetypeTableEvent #region Dimension style table event private static RhinoTableCallback g_on_dim_style_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnDimStyleTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_dim_style_table_event?.SafeInvoke(null, new DimStyleTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -3777,6 +3833,7 @@ public static event EventHandler DimensionStyleTableEven #endregion private static RhinoTableCallback g_on_idef_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnIdefTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_idef_table_event?.SafeInvoke(null, new InstanceDefinitionTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -3819,6 +3876,7 @@ public static event EventHandler InstanceDefin } private static RhinoTableCallback g_on_light_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnLightTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_light_table_event?.SafeInvoke(null, new LightTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -3862,6 +3920,7 @@ public static event EventHandler LightTableEvent private static RhinoTableCallback g_on_material_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnMaterialTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { if (m_material_table_event != null) @@ -3910,6 +3969,7 @@ public static event EventHandler MaterialTableEvent private static RhinoTableCallback g_on_group_table_event_callback; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] private static void OnGroupTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) { m_group_table_event?.SafeInvoke(null, new GroupTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); @@ -4004,6 +4064,7 @@ internal RenderContentTableEventArgs(RhinoDoc document, RenderContentTableEventT private readonly RenderContentTableEventType m_event_type; } private static RenderContentTableEventForwarder.ContentListLoadedCallback g_on_render_content_loaded_event_callback; + [MonoPInvokeCallback(typeof(RenderContentTableEventForwarder.ContentListLoadedCallback))] private static void OnRenderContentdLoadedEvent(int kind, uint docSerialNumber) { var document = FromRuntimeSerialNumber(docSerialNumber); @@ -4021,17 +4082,20 @@ private static void OnRenderContentdLoadedEvent(int kind, uint docSerialNumber) } } private static RenderContentTableEventForwarder.MaterialAssigmentChangedCallback g_on_object_material_assignment_changed_event_callback; + [MonoPInvokeCallback(typeof(RenderContentTableEventForwarder.MaterialAssigmentChangedCallback))] private static void OnObjectMaterialAssignmentChangedEvent(uint docSerialNumber, Guid objectId, Guid newMaterialId, Guid oldMaterialId) { OnMaterialAssignmentChangedCustomEvent(docSerialNumber, true, objectId, newMaterialId, oldMaterialId); } private static RenderContentTableEventForwarder.MaterialAssigmentChangedCallback g_on_layer_material_assignment_changed_event_callback; + [MonoPInvokeCallback(typeof(RenderContentTableEventForwarder.MaterialAssigmentChangedCallback))] private static void OnLayerMaterialAssignmentChangedEvent(uint docSerialNumber, Guid layerId, Guid newMaterialId, Guid oldMaterialId) { OnMaterialAssignmentChangedCustomEvent(docSerialNumber, false, layerId, newMaterialId, oldMaterialId); } private static RenderContentTableEventForwarder.ContentListClearingCallback g_on_render_content_clearing_event_callback; + [MonoPInvokeCallback(typeof(RenderContentTableEventForwarder.ContentListClearingCallback))] private static void OnRenderContentdClearingEvent(int kind, uint docSerialNumber) { var document = FromRuntimeSerialNumber(docSerialNumber); @@ -4050,6 +4114,7 @@ private static void OnRenderContentdClearingEvent(int kind, uint docSerialNumber } private static RenderContentTableEventForwarder.ContentListClearedCallback g_on_render_content_cleared_event_callback; + [MonoPInvokeCallback(typeof(RenderContentTableEventForwarder.ContentListClearedCallback))] private static void OnRenderContentdClearedEvent(int kind, uint docSerialNumber) { var document = FromRuntimeSerialNumber(docSerialNumber); @@ -4669,6 +4734,10 @@ public class RhinoObjectSelectionEventArgs : EventArgs private readonly IntPtr m_pRhinoObject; private readonly IntPtr m_pRhinoObjectList; + private RhinoDoc m_doc; + private RhinoObject[] m_objects; + + internal RhinoObjectSelectionEventArgs(bool select, uint docSerialNumber, IntPtr pRhinoObject, IntPtr pRhinoObjects) { Selected = select; @@ -4684,14 +4753,27 @@ internal RhinoObjectSelectionEventArgs(bool select, uint docSerialNumber, IntPtr /// 5.0 public bool Selected { get; } - RhinoDoc m_doc; /// 5.0 public RhinoDoc Document { get { return m_doc ?? (m_doc = RhinoDoc.FromRuntimeSerialNumber(m_doc_serial_number)); } } - List m_objects; + /// + /// Can be faster to call than RhinoObjects.Length + /// + public int RhinoObjectCount + { + get + { + if (m_objects != null) + return m_objects.Length; + if (m_pRhinoObjectList != IntPtr.Zero && m_pRhinoObject == IntPtr.Zero) + return UnsafeNativeMethods.RhinoObjectArray_Count(m_pRhinoObjectList); + return RhinoObjects.Length; + } + } + /// 5.0 public RhinoObject[] RhinoObjects { @@ -4699,20 +4781,26 @@ public RhinoObject[] RhinoObjects { if (m_objects == null) { - m_objects = new List(); + var objects = new List(); if (m_pRhinoObject != IntPtr.Zero) { RhinoObject rhobj = RhinoObject.CreateRhinoObjectHelper(m_pRhinoObject); if (rhobj != null) - m_objects.Add(rhobj); + objects.Add(rhobj); } if (m_pRhinoObjectList != IntPtr.Zero) { RhinoObject[] rhobjs = Runtime.InternalRhinoObjectArray.ToArrayFromPointer(m_pRhinoObjectList, true); - m_objects.AddRange(rhobjs); + if (objects.Count == 0) + { + m_objects = rhobjs; + return m_objects; } + objects.AddRange(rhobjs); + } + m_objects = objects.ToArray(); } - return m_objects.ToArray(); + return m_objects; } } } @@ -6131,7 +6219,8 @@ public Guid Add(GeometryBase geometry, ObjectAttributes attributes, HistoryRecor case ObjectType.Phantom: throw new NotImplementedException("Add currently does not support phantom types."); case ObjectType.ClipPlane: - throw new NotSupportedException("Add currently does not support clipping planes."); + obj_id = AddClippingPlaneSurface((ClippingPlaneSurface)geometry, attributes, history, reference); + break; case ObjectType.Extrusion: obj_id = AddExtrusion((Extrusion)geometry, attributes, history, reference); break; @@ -7413,6 +7502,15 @@ public Guid AddExtrusion(Extrusion extrusion, ObjectAttributes attributes, Histo return UnsafeNativeMethods.CRhinoDoc_AddExtrusion(m_doc.RuntimeSerialNumber, pConstExtrusion, pConstAttributes, pHistory, reference); } + public Guid AddClippingPlaneSurface(Geometry.ClippingPlaneSurface clippingPlane, ObjectAttributes attributes, HistoryRecord history, bool reference) + { + IntPtr pConstClippingPlane = clippingPlane.ConstPointer(); + IntPtr pConstAttributes = IntPtr.Zero; + IntPtr pHistory = (history == null) ? IntPtr.Zero : history.Handle; + if (attributes != null) pConstAttributes = attributes.ConstPointer(); + return UnsafeNativeMethods.CRhinoDoc_AddClippingPlaneSurface(m_doc.RuntimeSerialNumber, pConstClippingPlane, pConstAttributes, pHistory, reference); + } + /// Adds a mesh object to Rhino. /// A duplicate of this mesh is added to Rhino. /// A unique identifier for the object. @@ -7442,7 +7540,6 @@ public Guid AddMesh(Mesh mesh, ObjectAttributes attributes, HistoryRecord histor return AddMesh(mesh, attributes, history, reference, true); } - /// 6.0 public Guid AddMesh(Mesh mesh, ObjectAttributes attributes, HistoryRecord history, bool reference, bool requireValidMesh) { @@ -9443,6 +9540,7 @@ public BoundingBox BoundingBoxVisible /// /// Destroys the cached scene bounding box so that it will be regenerated again from scratch next time the view is regenerated /// + /// 8.8 public void InvalidateBoundingBox() { UnsafeNativeMethods.CRhinoDoc_InvalidateBoundingBox(m_doc.RuntimeSerialNumber); @@ -9793,7 +9891,7 @@ private IEnumerator GetEnumerator(ObjectEnumeratorSettings settings return it; } - private class EnumeratorWrapper : IEnumerable + private class EnumeratorWrapper : IEnumerable, IDisposable { readonly IEnumerator m_enumerator; public EnumeratorWrapper(IEnumerator enumerator) @@ -9801,6 +9899,13 @@ public EnumeratorWrapper(IEnumerator enumerator) m_enumerator = enumerator; } + public void Dispose() + { + IDisposable eDisposable = m_enumerator as IDisposable; + if (eDisposable != null) + eDisposable.Dispose(); + } + public IEnumerator GetEnumerator() { return m_enumerator; @@ -9913,11 +10018,35 @@ public IEnumerable GetSelectedObjects(bool includeLights, bool incl return GetObjectList(s); } + /// + /// Quick way to test if any objects are currently selected + /// + /// the type of objects to test for + /// Check to see if subobjects are selected + /// + [CLSCompliant(false)] + public bool SelectedObjectsExist(ObjectType objectType, bool checkSubObjects) + { + return UnsafeNativeMethods.CRhinoDoc_DoSelectedObjectsExist(m_doc.RuntimeSerialNumber, (uint)objectType, checkSubObjects); + } + + /// What geometry types are currently selected /// 6.0 [CLSCompliant(false)] public ObjectType GetSelectedObjectTypes() { - return (ObjectType)UnsafeNativeMethods.CRhinoDoc_SelectedObjectTypes(m_doc.RuntimeSerialNumber); + return (ObjectType)UnsafeNativeMethods.CRhinoDoc_SelectedObjectTypes(m_doc.RuntimeSerialNumber, false); + } + + /// + /// Compute the current number of selected objects + /// + /// Check to see if subobjects are selected + /// + [CLSCompliant(false)] + public uint GetSelectedObjectCount(bool checkSubObjects) + { + return UnsafeNativeMethods.CRhinoDoc_SelectedObjectCount(m_doc.RuntimeSerialNumber, checkSubObjects); } /// 5.0 diff --git a/src/dotnet/rhino/rhinosdkdocproperties.cs b/src/dotnet/rhino/rhinosdkdocproperties.cs index c377c1eff..9b4dd5b50 100644 --- a/src/dotnet/rhino/rhinosdkdocproperties.cs +++ b/src/dotnet/rhino/rhinosdkdocproperties.cs @@ -347,6 +347,7 @@ public bool RestoreAnimated(int index, Display.RhinoViewport viewport, bool back /// Returns the current selection in the Named Views panel. If more than one such panel is open, /// it will return the selection in the most recently opened panel. /// + /// 8.5 public string[] Selection { get @@ -896,6 +897,9 @@ public string[] Names } } + /// + /// Layer State restoration flags + /// /// 6.14 [Flags, CLSCompliant(false)] public enum RestoreLayerProperties : uint @@ -903,66 +907,87 @@ public enum RestoreLayerProperties : uint /// /// Restore nothing /// + /// 6.14 None = 0x0, /// /// Restore current layer /// + /// 6.14 Current = 0x1, /// /// Restore layer visibility /// + /// 6.14 Visible = 0x2, /// /// Restore layer locked status /// + /// 6.14 Locked = 0x4, /// /// Restore layer color /// + /// 6.14 Color = 0x8, /// /// Restore layer linetype /// + /// 6.14 Linetype = 0x10, /// /// Restore layer print color /// + /// 6.14 PrintColor = 0x20, /// /// Restore layer print width /// + /// 6.14 PrintWidth = 0x40, /// /// Restore per-viewport layer visibility /// + /// 6.14 ViewportVisible = 0x80, /// /// Restore per-viewport layer color /// + /// 6.14 ViewportColor = 0x100, /// /// Restore per-viewport layer print color /// + /// 6.14 ViewportPrintColor = 0x200, /// /// Restore per-viewport layer print width /// + /// 6.14 ViewportPrintWidth = 0x400, /// /// Restore render material /// + /// 6.14 RenderMaterial = 0x800, /// /// Section style /// + /// 8.0 SectionStyle = 0x1000, /// /// New Detail On /// + /// 8.0 NewDetailOn = 0x2000, /// + /// Expanded/Collapsed state + /// + /// 8.12 + Expanded = 0x4000, + /// /// Restore all layer properties /// + /// 6.14 All = 0xFFFFFFFF } diff --git a/src/dotnet/rhino/rhinosdkfont.cs b/src/dotnet/rhino/rhinosdkfont.cs index 62aa8ddfd..898dbd6b6 100644 --- a/src/dotnet/rhino/rhinosdkfont.cs +++ b/src/dotnet/rhino/rhinosdkfont.cs @@ -391,6 +391,7 @@ public string EnglishFamilyName } /// Is this font installed on the system + /// 8.7 public bool IsInstalled { get @@ -404,6 +405,7 @@ public bool IsInstalled /// If this font is not installed on the system, try to find a substitute /// /// + /// 8.7 public Font GetSubstituteFont() { IntPtr constPtrThis = ConstPointer(); diff --git a/src/dotnet/rhino/rhinosdkgroup.cs b/src/dotnet/rhino/rhinosdkgroup.cs index 4d3a1075a..233794f25 100644 --- a/src/dotnet/rhino/rhinosdkgroup.cs +++ b/src/dotnet/rhino/rhinosdkgroup.cs @@ -655,6 +655,12 @@ public System.Collections.Specialized.NameValueCollection GetUserStrings() { return _GetUserStrings(); } + + /// 8.11 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.11 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); #endregion diff --git a/src/dotnet/rhino/rhinosdkhatchpattern.cs b/src/dotnet/rhino/rhinosdkhatchpattern.cs index d6e01988c..3e8025b48 100644 --- a/src/dotnet/rhino/rhinosdkhatchpattern.cs +++ b/src/dotnet/rhino/rhinosdkhatchpattern.cs @@ -714,6 +714,44 @@ public static HatchPattern Squares } #endregion + + #region user strings + /// + /// Attach a user string (key,value combination) to this geometry. + /// + /// id used to retrieve this string. + /// string associated with key. + /// true on success. + /// 8.9 + public bool SetUserString(string key, string value) => _SetUserString(key, value); + + /// + /// Gets user string from this geometry. + /// + /// id used to retrieve the string. + /// string associated with the key if successful. null if no key was found. + /// 8.9 + public string GetUserString(string key) => _GetUserString(key); + + /// + /// Gets the amount of user strings. + /// + /// 8.9 + public int UserStringCount => _UserStringCount; + + /// + /// Gets a copy of all (user key string, user value string) pairs attached to this geometry. + /// + /// A new collection. + /// 8.9 + public System.Collections.Specialized.NameValueCollection GetUserStrings() => _GetUserStrings(); + + /// 8.9 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.9 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); + #endregion } } diff --git a/src/dotnet/rhino/rhinosdkinstance.cs b/src/dotnet/rhino/rhinosdkinstance.cs index 93dabbc40..e20615cdb 100644 --- a/src/dotnet/rhino/rhinosdkinstance.cs +++ b/src/dotnet/rhino/rhinosdkinstance.cs @@ -6,6 +6,7 @@ using Rhino.Runtime.InteropWrappers; using System.ComponentModel; using Rhino.FileIO; +using Rhino.DocObjects.Custom; namespace Rhino.DocObjects { @@ -195,18 +196,41 @@ public bool UsesDefinition(int definitionIndex, out int nestingLevel) /// Explodes the instance reference into pieces. /// /// - /// If true, then nested instance references are recursively exploded into pieces - /// until actual geometry is found. If false, an InstanceObject is added to - /// the pieces out parameter when this InstanceObject has nested references. + /// If true, then nested instance references are recursively exploded into pieces until actual geometry is found. + /// If false, an InstanceObject is added to the pieces out parameter when this InstanceObject has nested references. /// /// An array of Rhino objects will be assigned to this out parameter during this call. /// An array of object attributes will be assigned to this out parameter during this call. /// An array of the previously applied transform matrices will be assigned to this out parameter during this call. /// 5.0 public void Explode(bool explodeNestedInstances, out RhinoObject[] pieces, out ObjectAttributes[] pieceAttributes, out Transform[] pieceTransforms) + { + Explode(false, Guid.Empty, explodeNestedInstances, out pieces, out pieceAttributes, out pieceTransforms); + } + + /// + /// Explodes the instance reference into pieces. + /// + /// + /// If true, pieces that are not visible will not be appended to the pieces out parameter. + /// + /// + /// If skipHiddenPieces is false, then viewportId is ignored. + /// If bSkipHiddenPieces is true and and viewportId is not Guid.Empty, then layer and object per viewport visibility settings are used. + /// If bSkipHiddenPieces is true and and viewport_id is Guid.Empty, then layer and object global visibility settings are used. + /// + /// + /// If true, then nested instance references are recursively exploded into pieces until actual geometry is found. + /// If false, an InstanceObject is added to the pieces out parameter when this InstanceObject has nested references. + /// + /// An array of Rhino objects will be assigned to this out parameter during this call. + /// An array of object attributes will be assigned to this out parameter during this call. + /// An array of the previously applied transform matrices will be assigned to this out parameter during this call. + /// 8.9 + public void Explode(bool skipHiddenPieces, Guid viewportId, bool explodeNestedInstances, out RhinoObject[] pieces, out ObjectAttributes[] pieceAttributes, out Transform[] pieceTransforms) { IntPtr const_ptr_this = ConstPointer(); - IntPtr ptr_piece_list = UnsafeNativeMethods.CRhinoInstanceObject_Explode(const_ptr_this, explodeNestedInstances); + IntPtr ptr_piece_list = UnsafeNativeMethods.CRhinoInstanceObject_Explode(const_ptr_this, skipHiddenPieces, viewportId, explodeNestedInstances); int count = UnsafeNativeMethods.CRhinoInstanceObjectPieceArray_Count(ptr_piece_list); pieces = new RhinoObject[count]; pieceAttributes = new ObjectAttributes[count]; @@ -224,6 +248,7 @@ public void Explode(bool explodeNestedInstances, out RhinoObject[] pieces, out O UnsafeNativeMethods.CRhinoInstanceObjectPieceArray_Delete(ptr_piece_list); } + /// /// Get a RhinoObject in this block /// @@ -661,19 +686,19 @@ public System.Drawing.Bitmap CreatePreviewBitmap(Display.DefinedViewportProjecti /// Creates a preview bitmap of the instance definition. /// /// Id of one of this definition's objects to draw selected. - /// The view projection. + /// The view projection. /// The display mode. /// The bitmap size in pixels. /// Specify true to apply DPI scaling (Windows-only). /// The preview bitmap if successful, null otherwise. /// 6.21 - public System.Drawing.Bitmap CreatePreviewBitmap(Guid definitionObjectId, Display.DefinedViewportProjection definedViewportProjection, DisplayMode displayMode, System.Drawing.Size bitmapSize, bool applyDpiScaling) + public System.Drawing.Bitmap CreatePreviewBitmap(Guid definitionObjectId, Display.DefinedViewportProjection viewportProjection, DisplayMode displayMode, System.Drawing.Size bitmapSize, bool applyDpiScaling) { IntPtr const_ptr = ConstPointer(); IntPtr ptr_rhino_dib = UnsafeNativeMethods.CRhinoInstanceDefinition_GetPreviewBitmap( const_ptr, definitionObjectId, - (int)definedViewportProjection, + (int)viewportProjection, (int)displayMode, bitmapSize.Width, bitmapSize.Height, @@ -683,6 +708,33 @@ public System.Drawing.Bitmap CreatePreviewBitmap(Guid definitionObjectId, Displa return bitmap; } + /// + /// Creates a preview bitmap of the instance definition. + /// + /// The id of the display mode to draw with. + /// The view projection. + /// The isometric camera angle. + /// Specify true to draw viewport decorations, such as grid and axes. + /// The bitmap size in pixels. + /// Specify true to apply DPI scaling (Windows-only). + /// The preview bitmap if successful, null otherwise. + /// 8.10 + public System.Drawing.Bitmap CreatePreviewBitmap(Guid displayModeId, Display.DefinedViewportProjection viewportProjection, Display.IsometricCamera isometricCamera, bool drawDecorations, System.Drawing.Size bitmapSize, bool applyDpiScaling) + { + IntPtr const_ptr = ConstPointer(); + IntPtr ptr_rhino_dib = UnsafeNativeMethods.CRhinoInstanceDefinition_GetPreviewBitmap2( + const_ptr, + displayModeId, + (int)viewportProjection, + (int)isometricCamera, + drawDecorations, + bitmapSize.Width, + bitmapSize.Height, + applyDpiScaling + ); + var bitmap = RhinoDib.ToBitmap(ptr_rhino_dib, true); + return bitmap; + } /// /// Returns the archive file status of a linked instance definition. @@ -1054,7 +1106,7 @@ public int Add(string name, string description, Point3d basePoint, GeometryBase /// The new name. /// The new description string. /// - /// If true, information message boxes pop up when illegal changes are attempted. + /// If false, information message boxes pop up when illegal changes are attempted. /// /// /// true if successful. @@ -1075,7 +1127,7 @@ public bool Modify(InstanceDefinition idef, string newName, string newDescriptio /// The new URL or hyperlink. /// The new description of the URL or hyperlink. /// - /// If true, information message boxes pop up when illegal changes are attempted. + /// If false, information message boxes pop up when illegal changes are attempted. /// /// /// true if successful. @@ -1094,7 +1146,7 @@ public bool Modify(InstanceDefinition idef, string newName, string newDescriptio /// The new name. /// The new description string. /// - /// If true, information message boxes pop up when illegal changes are attempted. + /// If false, information message boxes pop up when illegal changes are attempted. /// /// /// true if successful. @@ -1120,7 +1172,7 @@ public bool Modify(int idefIndex, string newName, string newDescription, bool qu /// The new URL or hyperlink. /// The new description of the URL or hyperlink. /// - /// If true, information message boxes pop up when illegal changes are attempted. + /// If false, information message boxes pop up when illegal changes are attempted. /// /// /// true if successful. @@ -1131,6 +1183,27 @@ public bool Modify(int idefIndex, string newName, string newDescription, string return UnsafeNativeMethods.CRhinoInstanceDefinitionTable_ModifyInstanceDefinition2(m_doc.RuntimeSerialNumber, idefIndex, newName, newDescription, newUrl, newUrlTag, quiet); } + /// + /// Modifies the instance definition user data. + /// Does not change instance definition ID or geometry. + /// + /// The index of the instance definition to be modified. + /// The user data to replace. + /// + /// If false, information message boxes pop up when illegal changes are attempted. + /// + /// + /// true if successful. + /// + public bool Modify(int idefIndex, UserData userData, bool quiet) + { + var rc = UnsafeNativeMethods.CRhinoInstanceDefinitionTable_ModifyInstanceDefinitionUserData(m_doc.RuntimeSerialNumber, idefIndex, userData.NonConstPointer(true), quiet); + + UserData.StoreInRuntimeList(userData); + + return rc; + } + /// /// Restores the instance definition to its previous state, /// if the instance definition has been modified and the modification can be undone. diff --git a/src/dotnet/rhino/rhinosdklayer.cs b/src/dotnet/rhino/rhinosdklayer.cs index bbe3089bc..d5ed45a66 100644 --- a/src/dotnet/rhino/rhinosdklayer.cs +++ b/src/dotnet/rhino/rhinosdklayer.cs @@ -974,6 +974,28 @@ public bool IsReferenceParentLayer } } + /// + /// Return true if the layer is visible in user interfaces that display layers. + /// Returns false if the layer not visible in user interfaces. + /// This is a runtime property that does not persist in .3dm files. + /// This property is also used by the Layers panel to filter layers. + /// + /// 8.9 + public bool IsVisibleInUserInterface + { + get + { + if (null != m_doc) + return UnsafeNativeMethods.CRhinoLayer_IsVisibleInRhinoUserInterface(m_doc.RuntimeSerialNumber, Index, false, false); + return false; + } + set + { + if (null != m_doc) + UnsafeNativeMethods.CRhinoLayer_IsVisibleInRhinoUserInterface(m_doc.RuntimeSerialNumber, Index, true, value); + } + } + /// /// Returns parent of a layer. /// @@ -1012,9 +1034,18 @@ public RenderMaterial RenderMaterial var result = Render.RenderContent.FromId(m_doc, m_set_render_material) as RenderMaterial; return result; } + // Get the document Id var doc_id = (null == m_doc ? 0 : m_doc.RuntimeSerialNumber); if (doc_id < 1) return null; + + var materialIndex = RenderMaterialIndex; + if (materialIndex >= 0 && materialIndex < m_doc.Materials.Count) + { + var material = m_doc.Materials[materialIndex]; + if (!material.IsDeleted) return material.RenderMaterial; + } + var pointer = ConstPointer(); // Get the render material associated with the layers render material // index into the documents material table. @@ -1335,6 +1366,7 @@ public bool SetUserString(string key, string value) InternalCommitChanges(); return rc; } + /// /// Gets user string from this geometry. /// @@ -1368,6 +1400,21 @@ public System.Collections.Specialized.NameValueCollection GetUserStrings() return _GetUserStrings(); } + /// 8.9 + public bool DeleteUserString(string key) + { + return SetUserString(key, null); + } + + /// 8.9 + public void DeleteAllUserStrings() + { + _DeleteAllUserStrings(); + InternalCommitChanges(); + } + #endregion + + #region IEquatable /// 6.0 public bool Equals(Layer other) { diff --git a/src/dotnet/rhino/rhinosdklinetype.cs b/src/dotnet/rhino/rhinosdklinetype.cs index 0f9c2c833..842fbcb9e 100644 --- a/src/dotnet/rhino/rhinosdklinetype.cs +++ b/src/dotnet/rhino/rhinosdklinetype.cs @@ -351,6 +351,7 @@ public void RemoveTaper() /// be interpreted as being in world distances. This is useful for cases /// like modeling a road as a single curve. /// + /// 8.6 public bool AlwaysModelDistances { get @@ -555,6 +556,43 @@ public string PatternString(bool millimeters) #endif + #region user strings + /// + /// Attach a user string (key,value combination) to this geometry. + /// + /// id used to retrieve this string. + /// string associated with key. + /// true on success. + /// 8.9 + public bool SetUserString(string key, string value) => _SetUserString(key, value); + + /// + /// Gets user string from this geometry. + /// + /// id used to retrieve the string. + /// string associated with the key if successful. null if no key was found. + /// 8.9 + public string GetUserString(string key) => _GetUserString(key); + + /// + /// Gets the amount of user strings. + /// + /// 8.9 + public int UserStringCount => _UserStringCount; + + /// + /// Gets a copy of all (user key string, user value string) pairs attached to this geometry. + /// + /// A new collection. + /// 8.9 + public System.Collections.Specialized.NameValueCollection GetUserStrings() => _GetUserStrings(); + + /// 8.9 + public bool DeleteUserString(string key) => SetUserString(key, null); + + /// 8.9 + public void DeleteAllUserStrings() => _DeleteAllUserStrings(); + #endregion } } diff --git a/src/dotnet/rhino/rhinosdkmeshobject.cs b/src/dotnet/rhino/rhinosdkmeshobject.cs index 76f9f2abc..aaa3af24f 100644 --- a/src/dotnet/rhino/rhinosdkmeshobject.cs +++ b/src/dotnet/rhino/rhinosdkmeshobject.cs @@ -64,9 +64,17 @@ protected Mesh SetMesh(Mesh mesh) { var raw_mesh_ptr = UnsafeNativeMethods.ON_Object_SharedPointer_Get(p_shared_ptr_to_old_mesh); - var new_mesh = new Mesh(raw_mesh_ptr, null); + Mesh new_mesh = null; + if (raw_mesh_ptr != IntPtr.Zero) + { + new_mesh = new Mesh(raw_mesh_ptr, null); new_mesh.ConvertToConstObjectWithSharedPointerParent(p_shared_ptr_to_old_mesh); + } + else + { + new_mesh = new Mesh(); + } return new_mesh; } diff --git a/src/dotnet/rhino/rhinosdkmouse.cs b/src/dotnet/rhino/rhinosdkmouse.cs index 693f911b0..7338b4306 100644 --- a/src/dotnet/rhino/rhinosdkmouse.cs +++ b/src/dotnet/rhino/rhinosdkmouse.cs @@ -6,6 +6,143 @@ namespace Rhino.UI { + /// + /// Keyboard key recognized by shortcuts + /// + public enum KeyboardKey : int + { + /// No key + None = 0, + /// Tab key + Tab = 0x09, + /// PageUp key + PageUp = 0x21, + /// PageDown key + PageDown = 0x22, + /// End key + End = 0x23, + /// Home key + Home = 0x24, + /// 0 key + Num0 = 48, + /// 1 key + Num1 = 49, + /// 2 key + Num2 = 50, + /// 3 key + Num3 = 51, + /// 4 key + Num4 = 52, + /// 5 key + Num5 = 53, + /// 6 key + Num6 = 54, + /// 7 key + Num7 = 55, + /// 8 key + Num8 = 56, + /// 9 key + Num9 = 57, + /// A key + A = 65, + /// B key + B = 66, + /// C key + C = 67, + /// D key + D = 68, + /// E key + E = 69, + /// F key + F = 70, + /// G key + G = 71, + /// H key + H = 72, + /// I key + I = 73, + /// J key + J = 74, + /// K key + K = 75, + /// L key + L = 76, + /// M key + M = 77, + /// N key + N = 78, + /// O key + O = 79, + /// P key + P = 80, + /// Q key + Q = 81, + /// R key + R = 82, + /// S key + S = 83, + /// T key + T = 84, + /// U key + U = 85, + /// V key + V = 86, + /// W key + W = 87, + /// X key + X = 88, + /// Y key + Y = 89, + /// Z key + Z = 90, + /// F1 key + F1 = 0x70, + /// F2 key + F2 = 0x71, + /// F3 key + F3 = 0x72, + /// F4 key + F4 = 0x73, + /// F5 key + F5 = 0x74, + /// F6 key + F6 = 0x75, + /// F7 key + F7 = 0x76, + /// F8 key + F8 = 0x77, + /// F9 key + F9 = 0x78, + /// F10 key + F10 = 0x79, + /// F11 key + F11 = 0x7A, + /// F12 key + F12 = 0x7B, + /// ; key + Semicolon = 0xBA, + /// + key + Equal = 0xBB, + /// , key + Comma = 0xBC, + /// - key + Minus = 0xBD, + /// . key + Period = 0xBE, + /// / key + Slash = 0xBF, + /// Backtick key + Grave = 0xC0, + /// [ key + LeftBracket = 0xDB, + /// Back slash key + BackSlash = 0xDC, + /// ] key + RightBracket = 0xDD, + /// Quote key + Quote = 0xDE, + } + /// 6.0 [Flags] public enum MouseButton @@ -16,13 +153,25 @@ public enum MouseButton Middle = 4, } + /// + /// Keyboard keys typically used in combination with other keys + /// /// 6.0 [Flags] public enum ModifierKey { + /// No key None = 0, + /// Ctrl key on Windows Control = 1, - Shift = 2 + /// Command key on Mac. This is treated the same as Control key on Windows + MacCommand = 1, + /// Shift key + Shift = 2, + /// Alt key + Alt = 4, + /// Control key on Mac + MacControl = 8 } @@ -107,9 +256,10 @@ public System.Drawing.Point ViewportPoint get { return m_point; } } + /// 8.8 public Gumball.GumballMode IsOverGumball() { - return (Gumball.GumballMode)UnsafeNativeMethods.CRhGumball_MouseOverMode(m_view_serial_number); + return (Gumball.GumballMode)UnsafeNativeMethods.RHC_Gumball_MouseOverMode(m_view_serial_number); } } diff --git a/src/dotnet/rhino/rhinosdkobject.cs b/src/dotnet/rhino/rhinosdkobject.cs index 4a4f1ca65..2943a0b23 100644 --- a/src/dotnet/rhino/rhinosdkobject.cs +++ b/src/dotnet/rhino/rhinosdkobject.cs @@ -2264,21 +2264,20 @@ public RenderPrimitiveList GetRenderPrimitiveList(ViewportInfo viewport, Rhino.D /// 8.0 public bool HasCustomRenderMeshes(MeshType mt, ViewportInfo vp, ref RenderMeshProvider.Flags flags, PlugIns.PlugIn plugin, Display.DisplayPipelineAttributes attrs) { - if (Document == null) + RhinoDoc doc = Document; + if (doc == null) return false; uint f = (uint)flags; - if (Document is object) f |= 8 /*RenderMeshProvider.Flags.IsDocumentObject*/; - if (vp == null) - vp = new ViewportInfo(); + IntPtr ptrViewport = (vp != null) ? vp.ConstPointer() : IntPtr.Zero; var ret = UnsafeNativeMethods.Rdk_CustomRenderMeshes_IManager_HasCustomMeshes( (int)mt, - vp.ConstPointer(), - Document.RuntimeSerialNumber, + ptrViewport, + doc.RuntimeSerialNumber, Id, ref f, (plugin==null) ? IntPtr.Zero : plugin.NonConstPointer(), @@ -3109,18 +3108,51 @@ public bool HasHistoryRecord() var p_const_this = ConstPointer(); return UnsafeNativeMethods.CRhinoObject_HasHistoryRecord(p_const_this); } + /// - /// Sets a history record on the + /// For expert use only. + /// Sets the history record that describes how this object was created. + /// This information is used to update this object when Rhino history is enabled and an input object changes. /// - /// The history record to set for the object - /// true if successful + /// The history record. + /// true if successful, otherwise false. /// 8.0 public bool SetHistory(HistoryRecord history) { - var p_this = NonConstPointer(); - + var p_this = NonConstPointer_I_KnowWhatImDoing(); return UnsafeNativeMethods.CRhinoObject_SetHistory(p_this, history.Handle); } + + /// + /// Gets the ids of the parent Rhino objects of this object. + /// + /// An array of Rhino object ids if successful, an empty array if the object has no parents or on error. + /// 8.13 + public Guid[] HistoryParents() + { + using (var array = new SimpleArrayGuid()) + { + IntPtr ptr_const_this = ConstPointer(); + UnsafeNativeMethods.CRhinoObject_GetParents(ptr_const_this, array.NonConstPointer()); + return array.ToArray(); + } + } + + /// + /// Gets the ids of the child Rhino objects of this object. + /// + /// An array of Rhino object ids if successful, an empty array if the object has no children or on error. + /// 8.13 + public Guid[] HistoryChildren() + { + using (var array = new SimpleArrayGuid()) + { + IntPtr ptr_const_this = ConstPointer(); + UnsafeNativeMethods.CRhinoObject_GetChildren(ptr_const_this, array.NonConstPointer()); + return array.ToArray(); + } + } + internal bool IsCustom { get @@ -3884,7 +3916,7 @@ public static DocObjects.RhinoObject[] ToArrayFromPointer(IntPtr pRhinoObjectArr if (IntPtr.Zero == pRhinoObjectArray) return new DocObjects.RhinoObject[0]; - var count = UnsafeNativeMethods.RhinoObjectArray_Count(pRhinoObjectArray); + int count = UnsafeNativeMethods.RhinoObjectArray_Count(pRhinoObjectArray); var rc = new DocObjects.RhinoObject[count]; for (var i = 0; i < count; i++) { diff --git a/src/dotnet/rhino/rhinosdkobjectattributes.cs b/src/dotnet/rhino/rhinosdkobjectattributes.cs index 36d0c13a7..70166cfda 100644 --- a/src/dotnet/rhino/rhinosdkobjectattributes.cs +++ b/src/dotnet/rhino/rhinosdkobjectattributes.cs @@ -1160,6 +1160,18 @@ public int[] GetGroupList() return rc; } + /// + /// Determines if an object belong to a group or not. + /// + /// The index that will be tested. + /// + /// 8.11 + public bool IsInGroup(int groupIndex) + { + IntPtr ptr = ConstPointer(); + return UnsafeNativeMethods.ON_3dmObjectAttributes_IsInGroup(ptr, groupIndex); + } + // [skipping] // int TopGroup() const; I'm not sure how this is used // BOOL IsInGroup() diff --git a/src/dotnet/rhino/rhinosdkobjectmanager.cs b/src/dotnet/rhino/rhinosdkobjectmanager.cs index 704b21281..b9ac0175e 100644 --- a/src/dotnet/rhino/rhinosdkobjectmanager.cs +++ b/src/dotnet/rhino/rhinosdkobjectmanager.cs @@ -40,6 +40,7 @@ public enum ObjectManagerEventHints { None = UnsafeNativeMethods.RhinoEventWatcherObjectManagerHints.None, SelectionChanged = UnsafeNativeMethods.RhinoEventWatcherObjectManagerHints.SelectionChanged, + QuickAccessPropertyChanged = UnsafeNativeMethods.RhinoEventWatcherObjectManagerHints.QuickAccessPropertyChanged, RebuildRequired = UnsafeNativeMethods.RhinoEventWatcherObjectManagerHints.RebuildRequired, } @@ -303,6 +304,7 @@ private static ObjectManagerExtension FromSerialNumber(int serial) public delegate Guid PlugInIdDelegate(int serial); private static PlugInIdDelegate DelegatePlugInId = OnPlugInId; + [MonoPInvokeCallback(typeof(PlugInIdDelegate))] private static Guid OnPlugInId(int sn) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -315,6 +317,7 @@ private static Guid OnPlugInId(int sn) public delegate Guid ExtensionIdDelegate(int serial); private static ExtensionIdDelegate DelegateExtensionId = OnExtensionId; + [MonoPInvokeCallback(typeof(ExtensionIdDelegate))] private static Guid OnExtensionId(int sn) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -327,6 +330,7 @@ private static Guid OnExtensionId(int sn) public delegate void ExtensionEnglishNameDelegate(int serial, IntPtr pOut); private static ExtensionEnglishNameDelegate DelegateExtensionEnglishName = OnExtensionEnglishName; + [MonoPInvokeCallback(typeof(ExtensionEnglishNameDelegate))] private static void OnExtensionEnglishName(int sn, IntPtr pOut) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -343,6 +347,7 @@ private static void OnExtensionEnglishName(int sn, IntPtr pOut) public delegate void ExtensionLocalizedNameDelegate(int serial, IntPtr pOut); private static ExtensionLocalizedNameDelegate DelegateExtensionLocalizedName = OnExtensionLocalizedName; + [MonoPInvokeCallback(typeof(ExtensionLocalizedNameDelegate))] private static void OnExtensionLocalizedName(int sn, IntPtr pOut) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -359,6 +364,7 @@ private static void OnExtensionLocalizedName(int sn, IntPtr pOut) public delegate IntPtr ExtensionNodeFromArchiveDelegate(int serial, Guid idType, FileIO.BinaryArchiveWriter archive); private static ExtensionNodeFromArchiveDelegate DelegateExtensionNodeFromArchive = OnExtensionNodeFromArchive; + [MonoPInvokeCallback(typeof(ExtensionNodeFromArchiveDelegate))] private static IntPtr OnExtensionNodeFromArchive(int sn, Guid idType, FileIO.BinaryArchiveWriter archive) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -375,6 +381,7 @@ private static IntPtr OnExtensionNodeFromArchive(int sn, Guid idType, FileIO.Bin public delegate void ExtensionChildNodesDelegate(int serial, IntPtr pNode, IntPtr pNodes); private static ExtensionChildNodesDelegate DelegateExtensionChildNodes = OnExtensionChildNodes; + [MonoPInvokeCallback(typeof(ExtensionChildNodesDelegate))] private static void OnExtensionChildNodes(int sn, IntPtr pNode, IntPtr pNodes) { var ext = ObjectManagerExtension.FromSerialNumber(sn); @@ -785,7 +792,7 @@ public string FullyQualifiedId public abstract bool WriteToArchive(BinaryArchiveWriter archive); - public abstract ObjectManagerNodeCommandEnumerator Commands { get; } + public abstract ObjectManagerNodeCommand[] Commands { get; } public abstract ObjectManagerNodeCommand[] CommandsForNodes(ObjectManagerNode[] nodes); @@ -815,6 +822,7 @@ private static ObjectManagerNode FromSerialNumber(int serial) public delegate Guid NodeTypeIdDelegate(int serial); private static NodeTypeIdDelegate DelegateNodeTypeId = OnNodeTypeId; + [MonoPInvokeCallback(typeof(NodeTypeIdDelegate))] private static Guid OnNodeTypeId(int sn) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -827,6 +835,7 @@ private static Guid OnNodeTypeId(int sn) public delegate void NodeEnglishNameDelegate(int serial, IntPtr pOut); private static NodeEnglishNameDelegate DelegateNodeEnglishName = OnNodeEnglishName; + [MonoPInvokeCallback(typeof(NodeEnglishNameDelegate))] private static void OnNodeEnglishName(int sn, IntPtr pOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -843,6 +852,7 @@ private static void OnNodeEnglishName(int sn, IntPtr pOut) public delegate void NodeLocalizedNameDelegate(int serial, IntPtr pOut); private static NodeLocalizedNameDelegate DelegateNodeLocalizedName = OnNodeLocalizedName; + [MonoPInvokeCallback(typeof(NodeLocalizedNameDelegate))] private static void OnNodeLocalizedName(int sn, IntPtr pOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -859,6 +869,7 @@ private static void OnNodeLocalizedName(int sn, IntPtr pOut) public delegate void NodeIdDelegate(int serial, IntPtr pOut); private static NodeIdDelegate DelegateNodeId = OnNodeId; + [MonoPInvokeCallback(typeof(NodeIdDelegate))] private static void OnNodeId(int sn, IntPtr pOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -875,6 +886,7 @@ private static void OnNodeId(int sn, IntPtr pOut) public delegate IntPtr NodeParentDelegate(int serial); private static NodeParentDelegate DelegateParentNode = OnParentNode; + [MonoPInvokeCallback(typeof(NodeParentDelegate))] private static IntPtr OnParentNode(int sn) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -891,6 +903,7 @@ private static IntPtr OnParentNode(int sn) public delegate int NodeImageDelegate(int serial, int width, int height, ObjectManagerImageUsage usage, IntPtr pDibOut); private static NodeImageDelegate DelegateNodeImage = OnNodeImage; + [MonoPInvokeCallback(typeof(NodeImageDelegate))] private static int OnNodeImage(int sn, int width, int height, ObjectManagerImageUsage usage, IntPtr pDibOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -912,6 +925,7 @@ private static int OnNodeImage(int sn, int width, int height, ObjectManagerImage public delegate int NodePreviewDelegate(int serial, int width, int height, IntPtr pDibOut); private static NodePreviewDelegate DelegateNodePreview = OnNodePreview; + [MonoPInvokeCallback(typeof(NodePreviewDelegate))] private static int OnNodePreview(int sn, int width, int height, IntPtr pDibOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -933,6 +947,7 @@ private static int OnNodePreview(int sn, int width, int height, IntPtr pDibOut) public delegate void NodeChildrenDelegate(int serial, IntPtr pNode); private static NodeChildrenDelegate DelegateChildrenNode = OnChildrenNode; + [MonoPInvokeCallback(typeof(NodeChildrenDelegate))] private static void OnChildrenNode(int sn, IntPtr pNodeVector) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -952,6 +967,7 @@ private static void OnChildrenNode(int sn, IntPtr pNodeVector) public delegate void NodePropertiesDelegate(int serial, IntPtr pNodeVector); private static NodePropertiesDelegate DelegateNodeProperties = OnNodeProperties; + [MonoPInvokeCallback(typeof(NodePropertiesDelegate))] private static void OnNodeProperties(int sn, IntPtr pNodeVector) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -971,6 +987,7 @@ private static void OnNodeProperties(int sn, IntPtr pNodeVector) public delegate IntPtr NodeBeginChangeDelegate(int serial); private static NodeBeginChangeDelegate DelegateNodeBeginChange = OnNodeBeginChange; + [MonoPInvokeCallback(typeof(NodeBeginChangeDelegate))] private static IntPtr OnNodeBeginChange(int sn) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -987,6 +1004,7 @@ private static IntPtr OnNodeBeginChange(int sn) public delegate int NodeEndChangeDelegate(int serial); private static NodeEndChangeDelegate DelegateNodeEndChange = OnNodeEndChange; + [MonoPInvokeCallback(typeof(NodeEndChangeDelegate))] private static int OnNodeEndChange(int sn) { var property = ObjectManagerNode.FromSerialNumber(sn); @@ -1015,6 +1033,7 @@ private static IntPtr OnNodeLookupProperty(int sn, Guid property_id) public delegate void NodeCommandsDelegate(int serial, IntPtr pNodeVector); private static NodeCommandsDelegate DelegateNodeCommands = OnNodeCommands; + [MonoPInvokeCallback(typeof(NodeCommandsDelegate))] private static void OnNodeCommands(int sn, IntPtr pNodeVector) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1034,6 +1053,7 @@ private static void OnNodeCommands(int sn, IntPtr pNodeVector) public delegate void NodeCommandsForNodesDelegate(int serial, IntPtr pNodes, IntPtr pCommands); private static NodeCommandsForNodesDelegate DelegateNodeCommandsForNodes = OnNodeCommandsForNodes; + [MonoPInvokeCallback(typeof(NodeCommandsForNodesDelegate))] private static void OnNodeCommandsForNodes(int sn, IntPtr pNodes, IntPtr pCommands) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1069,6 +1089,7 @@ private static void OnNodeCommandsForNodes(int sn, IntPtr pNodes, IntPtr pComman public delegate int NodeWriteToBufferDelegate(int serial, IntPtr pArchive); private static NodeWriteToBufferDelegate DelegateNodeWriteToBuffer = OnNodeWriteToBuffer; + [MonoPInvokeCallback(typeof(NodeWriteToBufferDelegate))] private static int OnNodeWriteToBuffer(int sn, IntPtr pArchive) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1083,6 +1104,7 @@ private static int OnNodeWriteToBuffer(int sn, IntPtr pArchive) public delegate int NodeIsDragableDelegate(int serial); private static NodeIsDragableDelegate DelegateNodeIsDragable = OnNodeIsDragable; + [MonoPInvokeCallback(typeof(NodeIsDragableDelegate))] private static int OnNodeIsDragable(int sn) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1095,6 +1117,7 @@ private static int OnNodeIsDragable(int sn) public delegate int NodeSupportsDropTargetDelegate(int serial, IntPtr pDropTarget); private static NodeSupportsDropTargetDelegate DelegateNodeSupportsDropTarget = OnNodeSupportsDropTarget; + [MonoPInvokeCallback(typeof(NodeSupportsDropTargetDelegate))] private static int OnNodeSupportsDropTarget(int sn, IntPtr pDropTarget) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1109,6 +1132,7 @@ private static int OnNodeSupportsDropTarget(int sn, IntPtr pDropTarget) public delegate int NodeDropDelegate(int serial, IntPtr pDropTarget); private static NodeDropDelegate DelegateNodeDrop = OnNodeDrop; + [MonoPInvokeCallback(typeof(NodeDropDelegate))] private static int OnNodeDrop(int sn, IntPtr pDropTarget) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1123,6 +1147,7 @@ private static int OnNodeDrop(int sn, IntPtr pDropTarget) public delegate void NodeAddUiSectionsDelegate(int serial, IntPtr pSectionHolder); private static NodeAddUiSectionsDelegate DelegateNodeAddUiSections = OnNodeAddUiSections; + [MonoPInvokeCallback(typeof(NodeAddUiSectionsDelegate))] private static void OnNodeAddUiSections(int sn, IntPtr pSectionHolder) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1136,6 +1161,7 @@ private static void OnNodeAddUiSections(int sn, IntPtr pSectionHolder) public delegate IntPtr NodeGetParameterDelegate(int serial, IntPtr pName); private static NodeGetParameterDelegate DelegateNodeGetParameter = OnNodeGetParameter; + [MonoPInvokeCallback(typeof(NodeGetParameterDelegate))] private static IntPtr OnNodeGetParameter(int sn, IntPtr pName) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1157,6 +1183,7 @@ private static IntPtr OnNodeGetParameter(int sn, IntPtr pName) public delegate int NodeSetParameterDelegate(int serial, IntPtr pName, IntPtr pValue); private static NodeSetParameterDelegate DelegateNodeSetParameter = OnNodeSetParameter; + [MonoPInvokeCallback(typeof(NodeSetParameterDelegate))] private static int OnNodeSetParameter(int sn, IntPtr pName, IntPtr pValue) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1175,6 +1202,7 @@ private static int OnNodeSetParameter(int sn, IntPtr pName, IntPtr pValue) public delegate int NodeIsEqualDelegate(int serial, IntPtr pNode); private static NodeIsEqualDelegate DelegateNodeIsEqual = OnNodeIsEqual; + [MonoPInvokeCallback(typeof(NodeIsEqualDelegate))] private static int OnNodeIsEqual(int sn, IntPtr pNode) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1192,6 +1220,7 @@ private static int OnNodeIsEqual(int sn, IntPtr pNode) public delegate void NodeHighlightInViewDelegate(int serial, IntPtr pDisplayPipeline, uint channel, IntPtr pDisplayPen); private static NodeHighlightInViewDelegate DelegateNodeHighlightInView = OnNodeHighlightInView; + [MonoPInvokeCallback(typeof(NodeHighlightInViewDelegate))] private static void OnNodeHighlightInView(int sn, IntPtr pDisplayPipeline, uint channel, IntPtr pDisplayPen) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1212,6 +1241,7 @@ private static void OnNodeHighlightInView(int sn, IntPtr pDisplayPipeline, uint public delegate int NodeIsSelectedDelegate(int serial, IntPtr pNode); private static NodeIsSelectedDelegate DelegateNodeIsSelected = OnNodeIsSelected; + [MonoPInvokeCallback(typeof(NodeIsSelectedDelegate))] private static int OnNodeIsSelected(int sn, IntPtr pNode) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1227,6 +1257,7 @@ private static int OnNodeIsSelected(int sn, IntPtr pNode) public delegate void NodeToolTipDelegate(int serial, IntPtr pOut); private static NodeToolTipDelegate DelegateNodeToolTip = OnNodeToolTip; + [MonoPInvokeCallback(typeof(NodeToolTipDelegate))] private static void OnNodeToolTip(int sn, IntPtr pOut) { var node = ObjectManagerNode.FromSerialNumber(sn); @@ -1477,11 +1508,34 @@ public override bool EndChange() return UnsafeNativeMethods.RhinoObjectManager_Node_EndChange(CppPointer); } - public override ObjectManagerNodeCommandEnumerator Commands + public override ObjectManagerNodeCommand[] Commands { get { - return new ObjectManagerNodeCommandEnumerator(CppPointer); + IntPtr pCommands = UnsafeNativeMethods.RhinoObjectManager_Node_Commands(CppPointer); + if (IntPtr.Zero != pCommands) + { + int count = UnsafeNativeMethods.RhinoObjectManager_NodeCommandVector_Count(pCommands); + if (count > 0) + { + var commands = new ObjectManagerNodeCommand[count]; + + for (int i = 0; i < count; i++) + { + IntPtr pCommand = UnsafeNativeMethods.RhinoObjectManager_NodeCommandVector_GetAt(pCommands, i); + if (IntPtr.Zero != pCommand) + { + commands[i] = new ObjectManagerNodeCommandNative(pCommand, true); + } + } + + UnsafeNativeMethods.RhinoObjectManager_NodeCommandVector_Delete(pCommands); + + return commands; + } + } + + return new ObjectManagerNodeCommand[0]; } } @@ -1555,7 +1609,11 @@ public override void AddUiSections(Rhino.UI.Controls.ICollapsibleSectionHolder h public override void HighlightInView(Rhino.Display.DisplayPipeline displayPipeline, uint channel, Rhino.Display.DisplayPen pen) { - UnsafeNativeMethods.RhinoObjectManager_Node_HighlightInView(CppPointer, displayPipeline.NonConstPointer(), channel, pen.ToNativePointer()); + // 29 July 2024 S. Baer (RH-83103) + // Remove memory leak for display pen + IntPtr ptrPen = pen.ToNativePointer(); + UnsafeNativeMethods.RhinoObjectManager_Node_HighlightInView(CppPointer, displayPipeline.NonConstPointer(), channel, ptrPen); + Rhino.Display.DisplayPen.DeleteNativePointer(ptrPen); } public override bool IsSelected @@ -1646,6 +1704,8 @@ public void Dispose() public abstract bool Editable { get; } + public abstract Rhino.Render.Variant.Types ParameterType { get; } + private static ObjectManagerNodeQuickAccessProperty FromSerialNumber(int serial) { foreach (var property in ObjectManagerNodeQuickAccessPropertyList.properties) @@ -1734,16 +1794,29 @@ private static int OnPropertyEditable(int sn) return property.Editable ? 1 : 0; } + + public delegate Rhino.Render.Variant.Types NodePropertyTypeDelegate(int serial); + + private static NodePropertyTypeDelegate DelegateNodePropertyParameterType = OnNodePropertyParameterType; + private static Rhino.Render.Variant.Types OnNodePropertyParameterType(int sn) + { + var property = ObjectManagerNodeQuickAccessProperty.FromSerialNumber(sn); + if (null == property) + return Rhino.Render.Variant.Types.Null; + + return property.ParameterType; + } + internal static void SetCppHooks(bool bInitialize) { if (bInitialize) { UnsafeNativeMethods.RhCmnObjectManagerNodeProperty_SetCallbacks(DelegateNodePropertyId, DelegateNodePropertyDisplayName, - DelegateNodePropertyParameterName,DelegateNodePropertyImage, DelegatePropertyEditable); + DelegateNodePropertyParameterName,DelegateNodePropertyImage, DelegatePropertyEditable, DelegateNodePropertyParameterType); } else { - UnsafeNativeMethods.RhCmnObjectManagerNodeProperty_SetCallbacks(null, null, null, null, null); + UnsafeNativeMethods.RhCmnObjectManagerNodeProperty_SetCallbacks(null, null, null, null, null, null); } } } @@ -1807,6 +1880,14 @@ public override bool Editable return UnsafeNativeMethods.RhinoObjectManager_Node_Property_Editable(CppPointer); } } + + public override Rhino.Render.Variant.Types ParameterType + { + get + { + return (Rhino.Render.Variant.Types)UnsafeNativeMethods.RhinoObjectManager_Node_Property_ParameterType(CppPointer); + } + } } @@ -1904,6 +1985,8 @@ public void Dispose() public abstract bool SupportsMultipleSelection { get; } + public abstract int MenuOrder { get; } + public abstract bool Execute(); public abstract ObjectManagerNodeCommand[] SubCommands { get; } @@ -2099,6 +2182,18 @@ private static void OnNodeCommandSubCommands(int sn, IntPtr pNodeVector) } } + public delegate int NodeCommandMenuOrderDelegate(int serial); + + private static NodeCommandMenuOrderDelegate DelegateNodeCommandMenuOrder = OnNodeCommandMenuOrder; + private static int OnNodeCommandMenuOrder(int sn) + { + var command = ObjectManagerNodeCommand.FromSerialNumber(sn); + if (null == command) + return 0; + + return command.MenuOrder; + } + internal static void SetCppHooks(bool bInitialize) { if (bInitialize) @@ -2106,12 +2201,12 @@ internal static void SetCppHooks(bool bInitialize) UnsafeNativeMethods.RhCmnObjectManagerNodeCommand_SetCallbacks(DelegateNodeCommandId, DelegateNodeCommandEnglishName, DelegateNodeCommandLocalizedName, DelegateNodeCommandImage, DelegateNodeCommandState, DelegateNodeCommandIsCheckbox, DelegateNodeCommandIsSeparator, DelegateNodeCommandExecute, DelegateNodeCommandIsDefault, DelegateNodeCommandIsEnabled, - DelegateNodeCommandIsRadioButton, DelegateNodeCommandSupportsMultipleSelection); + DelegateNodeCommandIsRadioButton, DelegateNodeCommandSupportsMultipleSelection, DelegateNodeCommandMenuOrder); } else { UnsafeNativeMethods.RhCmnObjectManagerNodeCommand_SetCallbacks(null, null, null, null, null, null, null, null, null, - null, null, null); + null, null, null, null); } } } @@ -2224,6 +2319,14 @@ public override bool IsDefault } } + public override int MenuOrder + { + get + { + return UnsafeNativeMethods.RhinoObjectManager_Node_Command_MenuOrder(CppPointer); + } + } + public override bool Execute() { return UnsafeNativeMethods.RhinoObjectManager_Node_Command_Execute(CppPointer); diff --git a/src/dotnet/rhino/rhinosdkobjectpropertiesdialogpage.cs b/src/dotnet/rhino/rhinosdkobjectpropertiesdialogpage.cs index dafe5e814..a2d02f129 100644 --- a/src/dotnet/rhino/rhinosdkobjectpropertiesdialogpage.cs +++ b/src/dotnet/rhino/rhinosdkobjectpropertiesdialogpage.cs @@ -646,6 +646,46 @@ public bool AnySelectedObject(bool allMustMatch) where T : RhinoObject { var type = typeof (T); var filter = allMustMatch ? ObjectType.AnyObject : TypeFilter(type); + + // 9 July 2024 S. Baer (RH-82891) + // Try to bail out as quick as possible by using the more efficient + // RhinoDoc functions. This function could be further optimized to not + // require any .NET looping through object lists. + uint docSerialNumber = RhinoPageHooks.RhinoDocRuntimeSerialNumberFromPage(this); + RhinoDoc doc = RhinoDoc.FromRuntimeSerialNumber(docSerialNumber); + if (doc != null) + { + if (!doc.Objects.SelectedObjectsExist(filter, true)) + return false; + + var objectlist = doc.Objects.GetObjectList(new ObjectEnumeratorSettings() { ObjectTypeFilter = filter, SelectedObjectsFilter = true }); + IDisposable disposable = objectlist as IDisposable; + bool listHasElements = false; + foreach (var rhinoObject in objectlist) + { + listHasElements = true; + var obj = rhinoObject as T; + // If all objects must match and this object does not then return false + if (allMustMatch && obj == null) + { + if (disposable != null) + disposable.Dispose(); + return false; + } + // No requirement for all objects to match and this one does then just return true now + if (!allMustMatch && obj != null) + { + if (disposable != null) + disposable.Dispose(); + return true; + } + } + if (disposable != null) + disposable.Dispose(); + return allMustMatch && listHasElements; + } + + // This code should never be hit anymore since doc should always exist var page_pointer = RhinoPageHooks.UnmanagedIRhinoPagePointerFromPage(this); var count = 0; var array_pointer = UnsafeNativeMethods.IRhinoPropertiesPanelPage_GetObjects(page_pointer, (uint)filter, ref count); diff --git a/src/dotnet/rhino/rhinosdkpagelayoutview.cs b/src/dotnet/rhino/rhinosdkpagelayoutview.cs index 8ddfc1828..55dc93dca 100644 --- a/src/dotnet/rhino/rhinosdkpagelayoutview.cs +++ b/src/dotnet/rhino/rhinosdkpagelayoutview.cs @@ -1,4 +1,5 @@ using Rhino.DocObjects; +using Rhino.Runtime; using Rhino.Runtime.InteropWrappers; #pragma warning disable 1591 using System; @@ -417,6 +418,40 @@ public static event EventHandler PageViewSpaceChan } } + internal delegate void PageViewPropertiesCallback(uint documentSerialNumber, uint pageviewSerialNumber); + private static PageViewPropertiesCallback g_pageview_properties_callback; + private static EventHandler g_pageview_properties_change; + private static void OnPageViewPropertiesChange(uint documentSerialNumber, uint pageViewSerialNumber) + { + g_pageview_properties_change?.SafeInvoke(null, new PageViewPropertiesChangeEventArgs(documentSerialNumber, pageViewSerialNumber)); + } + public static event EventHandler PageViewPropertiesChange + { + add + { + if (Runtime.HostUtils.ContainsDelegate(g_pageview_properties_change, value)) + return; + if (g_pageview_properties_change == null) + { + g_pageview_properties_callback = OnPageViewPropertiesChange; + UnsafeNativeMethods.CRhinoEventWatcher_SetPageViewPropertiesCallback(g_pageview_properties_callback); + } + // ReSharper disable once DelegateSubtraction + g_pageview_properties_change -= value; + g_pageview_properties_change += value; + } + remove + { + // ReSharper disable once DelegateSubtraction + g_pageview_properties_change -= value; + if (g_pageview_properties_change == null) + { + UnsafeNativeMethods.CRhinoEventWatcher_SetDetailEventCallback(null); + g_pageview_properties_callback = null; + } + } + } + } } #endif diff --git a/src/dotnet/rhino/rhinosdkplugin.cs b/src/dotnet/rhino/rhinosdkplugin.cs index 0d455de1f..adcb002b3 100644 --- a/src/dotnet/rhino/rhinosdkplugin.cs +++ b/src/dotnet/rhino/rhinosdkplugin.cs @@ -646,9 +646,10 @@ public virtual PlugInLoadTime LoadTime /// /// Called by Rhino to determine if the plug-in name should be added to the Rhino Help/Plug-ins menu. /// + /// 8.7 public virtual bool AddToHelpMenu { - get { return true; } + get { return false; } } /// @@ -656,6 +657,7 @@ public virtual bool AddToHelpMenu /// /// Native Window handle of the active Rhino interface. /// true = Help displayed successfully, false = Error displaying help + /// 8.7 public virtual bool DisplayHelp(IntPtr windowHandle) { return false; @@ -663,6 +665,8 @@ public virtual bool DisplayHelp(IntPtr windowHandle) internal delegate bool UnknownUserDataCallback(uint doc_serial, Guid plugin_id); private static readonly UnknownUserDataCallback g_unknown_userdata_callback = OnUnknownUserData; + + [MonoPInvokeCallback(typeof(UnknownUserDataCallback))] private static bool OnUnknownUserData(uint doc_serial, Guid plugin_id) { var doc = RhinoDoc.FromRuntimeSerialNumber(doc_serial); @@ -822,6 +826,7 @@ private static void LoadSaveProfile(int serialNumber, int load, IntPtr section, } + [MonoPInvokeCallback(typeof(OnDisplayHelpDelegate))] private static bool InternalOnDisplayHelp(int pluginSerialNumber, IntPtr hwndParent) { PlugIn p = LookUpBySerialNumber(pluginSerialNumber); @@ -840,6 +845,7 @@ private static bool InternalOnDisplayHelp(int pluginSerialNumber, IntPtr hwndPar + [MonoPInvokeCallback(typeof(OnLoadDelegate))] private static int InternalOnLoad(int pluginSerialNumber) { LoadReturnCode rc = LoadReturnCode.Success; @@ -912,6 +918,7 @@ private static int InternalOnLoad(int pluginSerialNumber) return (int)rc; } + [MonoPInvokeCallback(typeof(OnShutdownDelegate))] private static void InternalOnShutdown(int pluginSerialNumber) { PlugIn p = LookUpBySerialNumber(pluginSerialNumber); @@ -943,6 +950,7 @@ private static void InternalOnShutdown(int pluginSerialNumber) } } + [MonoPInvokeCallback(typeof(ResetMessageBoxesDelegate))] private static void InternalResetMessageBoxes(int pluginSerialNumber) { PlugIn p = LookUpBySerialNumber(pluginSerialNumber); @@ -959,6 +967,7 @@ private static void InternalResetMessageBoxes(int pluginSerialNumber) } } + [MonoPInvokeCallback(typeof(OnGetPlugInObjectDelegate))] private static IntPtr InternalOnGetPlugInObject(int pluginSerialNumber) { IntPtr rc = IntPtr.Zero; @@ -978,6 +987,7 @@ private static IntPtr InternalOnGetPlugInObject(int pluginSerialNumber) } return rc; } + [MonoPInvokeCallback(typeof(CallWriteDocumentDelegate))] private static int InternalCallWriteDocument(int pluginSerialNumber, IntPtr pWriteOptions) { int rc = 0; //FALSE @@ -991,6 +1001,7 @@ private static int InternalCallWriteDocument(int pluginSerialNumber, IntPtr pWri return rc; } + [MonoPInvokeCallback(typeof(DisplayOptionsDialogDelegate))] private static void DisplayOptionsDialogHook(int runtimeSerialNumber, IntPtr hwndParent, [MarshalAs(UnmanagedType.LPWStr)]string fileDescription, [MarshalAs(UnmanagedType.LPWStr)]string fileExtension) { var plugin = LookUpBySerialNumber(runtimeSerialNumber); @@ -1001,6 +1012,7 @@ private static void DisplayOptionsDialogHook(int runtimeSerialNumber, IntPtr hwn var export_plugin = plugin as FileExportPlugIn; export_plugin?.CallDisplayOptionsDialog(hwndParent, fileDescription, fileExtension); } + [MonoPInvokeCallback(typeof(EventHandler))] private static void InternalLocalPlugInName(object sender, Rhino.Runtime.NamedParametersEventArgs args) { if (args.TryGetInt("sn", out int sn) && sn > 0) @@ -1008,6 +1020,7 @@ private static void InternalLocalPlugInName(object sender, Rhino.Runtime.NamedPa } + [MonoPInvokeCallback(typeof(WriteDocumentDelegate))] private static int InternalWriteDocument(int pluginSerialNumber, uint docSerialNumber, IntPtr pBinaryArchive, IntPtr pWriteOptions) { int rc = 1; //TRUE @@ -1033,6 +1046,7 @@ private static int InternalWriteDocument(int pluginSerialNumber, uint docSerialN } return rc; } + [MonoPInvokeCallback(typeof(ReadDocumentDelegate))] private static int InternalReadDocument(int pluginSerialNumber, uint docSerialNumber, IntPtr pBinaryArchive, IntPtr pReadOptions) { int rc = 1; //TRUE @@ -1059,6 +1073,7 @@ private static int InternalReadDocument(int pluginSerialNumber, uint docSerialNu return rc; } + [MonoPInvokeCallback(typeof(OnAddPagesToObjectPropertiesDelegate))] private static void InternalAddPagesToObjectProperties(int pluginSerialNumber, int mode, uint documentRuntimeSerialNumber, IntPtr collectionPointer) { var plug_in = LookUpBySerialNumber(pluginSerialNumber); @@ -1086,6 +1101,7 @@ private static void InternalAddPagesToObjectProperties(int pluginSerialNumber, i } } + [MonoPInvokeCallback(typeof(OnAddSectionsToSunPanelDelegate))] private static void InternalAddPagesToSunPanel(int pluginSerialNumber, uint modal, IntPtr pSectionList) { RenderPlugIn plug_in = LookUpBySerialNumber(pluginSerialNumber) as RenderPlugIn; @@ -1120,6 +1136,7 @@ private static void InternalAddPagesToSunPanel(int pluginSerialNumber, uint moda } } + [MonoPInvokeCallback(typeof(OnAddSectionsToRenderSettingsPanelDelegate))] private static void InternalAddPagesToRenderSettingsPanel(int pluginSerialNumber, uint modal, IntPtr pSectionList) { RenderPlugIn plug_in = LookUpBySerialNumber(pluginSerialNumber) as RenderPlugIn; @@ -1154,11 +1171,13 @@ private static void InternalAddPagesToRenderSettingsPanel(int pluginSerialNumber } } + [MonoPInvokeCallback(typeof(OnPlugInProcDelegate))] private static uint InternalPlugInProc(int pluginSerialNumber, uint message, IntPtr wParam, IntPtr lParam) { return 0; } + [MonoPInvokeCallback(typeof(OnAddPagesToOptionsDelegate))] private static void InternalAddPagesToOptions(int pluginSerialNumber, uint documentRuntimeSerialNumber, IntPtr collectionPointer, int addToDocProps) { var plugin = LookUpBySerialNumber(pluginSerialNumber); @@ -2809,7 +2828,10 @@ private static CompatResult RunCompat(string path) // write error stream if needed var errout = sbError.ToString(); if (!string.IsNullOrWhiteSpace(errout)) + { DebugStringSafe("ERROR: " + errout); + output += "\n\n" + errout; + } if (proc.ExitCode == 112 ) System.Diagnostics.Debug.Write(output); @@ -2967,6 +2989,16 @@ static bool CreateFromAssembly(System.Reflection.Assembly pluginAssembly, bool d } return (rhcmn_plugin!=null); } + + /// + /// Returns true if this renderer can render the texture natively without needing it to be baked into a bitmap, false otherwise. + /// By default, returns false for all textures. + /// + /// 8.6 + public virtual bool IsTextureSupported(RenderTexture texture) + { + return UnsafeNativeMethods.Rdk_PlugIn_BaseClassIsTextureSupported(NonConstPointer(), texture.ConstPointer()); + } } /// @@ -3470,6 +3502,7 @@ protected FileImportPlugIn() private static AddFileType m_OnAddFileType; private static ReadFileFunc m_OnReadFile; + [MonoPInvokeCallback(typeof(AddFileType))] private static void InternalOnAddFileType(int pluginSerialNumber, IntPtr pFileList, IntPtr readoptions) { var p = LookUpBySerialNumber(pluginSerialNumber) as FileImportPlugIn; @@ -3509,6 +3542,7 @@ private static void InternalOnAddFileType(int pluginSerialNumber, IntPtr pFileLi } } + [MonoPInvokeCallback(typeof(ReadFileFunc))] private static int InternalOnReadFile(int pluginSerialNumber, IntPtr filename, int index, uint docSerialNumber, IntPtr readoptions) { int rc = 0; @@ -3850,7 +3884,7 @@ protected RenderPlugIn() g_render_settings_sections_callback, g_plugin_icon_callback, g_initial_channel_to_display, - g_plugin_texture_needs_baking, + g_plugin_is_texture_supported, m_customChannelName ); } @@ -4054,27 +4088,18 @@ private static Guid PlugInInitialChannelToDisplay(int serialNumber) return Guid.Empty; } - internal delegate bool PlugInTextureNeedsBakingCallback(int serialNumber, IntPtr pTexture); - private static readonly PlugInTextureNeedsBakingCallback g_plugin_texture_needs_baking = PlugInTextureNeedsBaking; - private static bool PlugInTextureNeedsBaking(int serialNumber, IntPtr pTexture) + internal delegate bool PlugInIsTextureSupportedCallback(int serialNumber, IntPtr pTexture); + private static readonly PlugInIsTextureSupportedCallback g_plugin_is_texture_supported = PlugInIsTextureSupported; + private static bool PlugInIsTextureSupported(int serialNumber, IntPtr pTexture) { // Get the runtime plug-in to call - var render_plug_in = LookUpBySerialNumber(serialNumber) as RenderPlugIn; - if (render_plug_in == null) + var plug_in = LookUpBySerialNumber(serialNumber) as PlugIn; + if (plug_in == null) return false; RenderTexture texture = (RenderTexture)RenderContent.FromPointer(pTexture, null); - return !render_plug_in.IsTextureSupported(texture); - } - - /// - /// Returns true if this renderer can render the texture natively without needing it to be baked into a bitmap, false otherwise. - /// By default, returns false for all textures. - /// - public virtual bool IsTextureSupported(RenderTexture texture) - { - return UnsafeNativeMethods.Rdk_RenderPlugIn_BaseClassIsTextureSupported(NonConstPointer(), texture.ConstPointer()); + return plug_in.IsTextureSupported(texture); } internal delegate bool SaveCusomtomRenderFileCallback(int serialNumber, [MarshalAs(UnmanagedType.LPWStr)]string fileName, [MarshalAs(UnmanagedType.LPWStr)]string fileType, Guid sessionId, bool includeAlpha); diff --git a/src/dotnet/rhino/rhinosdkpointobject.cs b/src/dotnet/rhino/rhinosdkpointobject.cs index b35e49006..2d03705c0 100644 --- a/src/dotnet/rhino/rhinosdkpointobject.cs +++ b/src/dotnet/rhino/rhinosdkpointobject.cs @@ -1,5 +1,6 @@ #pragma warning disable 1591 using System; +using System.Collections.Generic; using Rhino.Geometry; using Rhino.Runtime.InteropWrappers; @@ -67,7 +68,7 @@ internal override CommitGeometryChangesFunc GetCommitFunc() // I think CRhinoGripObjectEx can probably be merged with GripObject public class GripObject : RhinoObject { - internal GripObject() {} + internal GripObject() { } internal GripObject(uint serialNumber) : base(serialNumber) @@ -215,7 +216,7 @@ public GripObject NeighborGrip(int directionR, int directionS, int directionT, b { IntPtr const_ptr_this = ConstPointer(); uint sn = UnsafeNativeMethods.CRhinoGripObject_NeighborGrip(const_ptr_this, directionR, directionS, directionT, wrap); - if( sn!=0 ) + if (sn != 0) return new GripObject(sn); return null; } @@ -237,7 +238,7 @@ public bool GetGripDirections(out Vector3d u, out Vector3d v, out Vector3d norma } /// - /// Retrieves the 2d parameter space values of this GripObject from the surface it's associated with. + /// Retrieves the NURBS surface 2d parameter space values of this GripObject from the surface it's associated with. /// /// /// @@ -250,6 +251,60 @@ public bool GetSurfaceParameters(out double u, out double v) return UnsafeNativeMethods.CRhinoGripObject_GetSurfaceParameters(const_ptr_this, ref u, ref v); } + /// + /// Retrieves the NURBS curve control point indices of this GripObject from the curve it is associated with. + /// + /// The NURBS curve control point indices. + /// + /// The number of NURBS curve control points managed by this grip. + /// If the grip is not a curve control point, zero is returned. + /// + /// 8.10 + public int GetCurveCVIndices(out int[] cvIndices) + { + cvIndices = Array.Empty(); + using (var index_array = new SimpleArrayInt()) + { + IntPtr ptr_const_this = ConstPointer(); + var ptr_index_array = index_array.NonConstPointer(); + var count = UnsafeNativeMethods.CRhinoGripObject_GetCurveCVIndices(ptr_const_this, ptr_index_array); + if (count > 0) + cvIndices = index_array.ToArray(); + return cvIndices.Length; + } + } + + /// + /// Retrieves the NURBS surface control point indices of this GripObject from the surface it is associated with. + /// + /// The NURBS surface control point indices as tuples. + /// + /// The number of NURBS surface control points managed by this grip. + /// If the grip is not a surface control point, zero is returned. + /// + /// 8.10 + public int GetSurfaceCVIndices(out Tuple[] cvIndices) + { + cvIndices = Array.Empty>(); + using (var dex_array = new SimpleArray2dex()) + { + IntPtr ptr_const_this = ConstPointer(); + var ptr_dex = dex_array.NonConstPointer(); + var count = UnsafeNativeMethods.CRhinoGripObject_GetSurfaceCVIndices(ptr_const_this, ptr_dex); + if (count > 0) + { + var results = new List>(); + foreach (var dex in dex_array.ToArray()) + { + var uv = new Tuple(dex.I, dex.J); + results.Add(uv); + } + cvIndices = results.ToArray(); + } + return cvIndices.Length; + } + } + /// /// Retrieves the 2d parameter space values of this GripObject from the cage it's associated with. /// diff --git a/src/dotnet/rhino/rhinosdkprintinfo.cs b/src/dotnet/rhino/rhinosdkprintinfo.cs index 9585887cc..cd65a2fcc 100644 --- a/src/dotnet/rhino/rhinosdkprintinfo.cs +++ b/src/dotnet/rhino/rhinosdkprintinfo.cs @@ -707,6 +707,7 @@ public ViewCaptureSettings() /// Copy constructor /// settings to copy data from + /// 8.5 public ViewCaptureSettings(ViewCaptureSettings other) { IntPtr ptrOther = other != null ? other.ConstPointer() : IntPtr.Zero; @@ -770,6 +771,7 @@ public ViewCaptureSettings CreatePreviewSettings(System.Drawing.Size size) /// /// other settings to compare against /// + /// 8.5 [ConstOperation] public bool Equals(ViewCaptureSettings other) { @@ -896,6 +898,7 @@ public bool MatchLinetypePatternDefinition /// Should curves and edges have their thicknesses scaled based the on the display /// mode settings for a view being captured (default is false) /// + /// 8.5 public bool ApplyDisplayModeThicknessScales { get @@ -934,6 +937,7 @@ public Size MediaSize /// /// Rectangle where drawing is confined to on MediaSize /// + /// 8.5 public Rectangle DrawRectangle { get @@ -1052,6 +1056,7 @@ public bool SetMargins(UnitSystem lengthUnits, double left, double top, double r /// True if successful. /// False if unsuccessful (this could happen if there is no set device_dpi) /// + /// 8.5 public bool SetMarginLeft(UnitSystem lengthUnits, double distance) { GetMargins(lengthUnits, out double _, out double top, out double right, out double bottom); @@ -1067,6 +1072,7 @@ public bool SetMarginLeft(UnitSystem lengthUnits, double distance) /// True if successful. /// False if unsuccessful (this could happen if there is no set device_dpi) /// + /// 8.5 public bool SetMarginTop(UnitSystem lengthUnits, double distance) { GetMargins(lengthUnits, out double left, out double _, out double right, out double bottom); @@ -1082,6 +1088,7 @@ public bool SetMarginTop(UnitSystem lengthUnits, double distance) /// True if successful. /// False if unsuccessful (this could happen if there is no set device_dpi) /// + /// 8.5 public bool SetMarginRight(UnitSystem lengthUnits, double distance) { GetMargins(lengthUnits, out double left, out double top, out double _, out double bottom); @@ -1096,6 +1103,7 @@ public bool SetMarginRight(UnitSystem lengthUnits, double distance) /// True if successful. /// False if unsuccessful (this could happen if there is no set device_dpi) /// + /// 8.5 public bool SetMarginBottom(UnitSystem lengthUnits, double distance) { GetMargins(lengthUnits, out double left, out double top, out double right, out double _); @@ -1308,6 +1316,7 @@ public double DefaultPrintWidthMillimeters /// /// Horizontal stretch to be applied to output. Useful for calibrating printers /// + /// 8.4 public double HorizontalScale { get { return GetDouble(UnsafeNativeMethods.PrintInfoDouble.HorizontalScale); } @@ -1317,6 +1326,7 @@ public double HorizontalScale /// /// Vertical stretch to be applied to output. Useful for calibrating printers /// + /// 8.4 public double VerticalScale { get { return GetDouble(UnsafeNativeMethods.PrintInfoDouble.VerticalScale); } @@ -1500,6 +1510,7 @@ public bool LinetypeWidthUnitsArePageLengths } } + /// 8.1 public bool Load(string name, PersistentSettings settings) { IntPtr ptr_this = NonConstPointer(); @@ -1507,6 +1518,7 @@ public bool Load(string name, PersistentSettings settings) return UnsafeNativeMethods.CRhinoPrintInfo_Load(ptr_this, command_name, name); } + /// 8.1 public void Save(string name, PersistentSettings settings) { IntPtr const_ptr_this = ConstPointer(); @@ -2399,8 +2411,6 @@ void Point(int style, float screenX, float screenY, int fillArgb, int strokeArgb pointstyle == Display.PointStyle.RoundControlPoint || pointstyle == Display.PointStyle.RoundSimple) { - if (pointstyle == Display.PointStyle.RoundSimple) - stroke_width_points = 0; DrawCircle(center, diameter_points, fill_color, new Pen {Color=stroke_color, Width=stroke_width_points }); } else diff --git a/src/dotnet/rhino/rhinosdksnapshotsclient.cs b/src/dotnet/rhino/rhinosdksnapshotsclient.cs index e00ff99c5..edb91a919 100644 --- a/src/dotnet/rhino/rhinosdksnapshotsclient.cs +++ b/src/dotnet/rhino/rhinosdksnapshotsclient.cs @@ -434,6 +434,7 @@ private static SnapShotsClient FromSerialNumber(int serial) internal static GETGUIDPROC pluginid_proc = PlugInId; + [MonoPInvokeCallback(typeof(GETGUIDPROC))] private static Guid PlugInId(int serial) { var client = FromSerialNumber(serial); @@ -446,6 +447,7 @@ private static Guid PlugInId(int serial) } internal static GETGUIDPROC clientid_proc = ClientId; + [MonoPInvokeCallback(typeof(GETGUIDPROC))] private static Guid ClientId(int serial) { var client = FromSerialNumber(serial); @@ -458,6 +460,7 @@ private static Guid ClientId(int serial) } internal static SETINTINT animationstop_proc = AnimationStop; + [MonoPInvokeCallback(typeof(SETINTINT))] private static void AnimationStop(int serial, uint doc_serial) { var client = FromSerialNumber(serial); @@ -471,6 +474,7 @@ private static void AnimationStop(int serial, uint doc_serial) } internal static GETBOOLDOCOBJTRANSFORMDOUBLEBUFFERBUFFERPROC animateobject_proc = AnimateObject; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJTRANSFORMDOUBLEBUFFERBUFFERPROC))] private static int AnimateObject(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, double dPos, IntPtr pArchive_start, IntPtr pArchive_stop) { var client = FromSerialNumber(serial); @@ -489,6 +493,7 @@ private static int AnimateObject(int serial, uint doc_serial, uint obj_serial, r } internal static SETBOOLDOCOBJTRANSFORMBUFFERBUFFERBBOXPROC extendboundingboxforobjectanimation_proc = ExtendBoundingBoxForObjectAnimation; + [MonoPInvokeCallback(typeof(SETBOOLDOCOBJTRANSFORMBUFFERBUFFERBBOXPROC))] private static void ExtendBoundingBoxForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox) { var client = FromSerialNumber(serial); @@ -505,6 +510,7 @@ private static void ExtendBoundingBoxForObjectAnimation(int serial, uint pDoc_se } internal static GETBOOLDOCOBJTRANSFORMBUFFERBUFFERPROC prepareforobjectanimation_proc = PrepareForObjectAnimation; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJTRANSFORMBUFFERBUFFERPROC))] private static int PrepareForObjectAnimation(int serial, uint pDoc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive_start, IntPtr pArchive_stop) { var client = FromSerialNumber(serial); @@ -523,6 +529,7 @@ private static int PrepareForObjectAnimation(int serial, uint pDoc_serial, uint } internal static GETDOCDOUBLEBUFFERBUFFERPROC animatedocument_proc = AnimateDocument; + [MonoPInvokeCallback(typeof(GETDOCDOUBLEBUFFERBUFFERPROC))] private static int AnimateDocument(int serial, uint pDoc_serial, double dPos, IntPtr pArchive_start, IntPtr pArchive_stop) { var client = FromSerialNumber(serial); @@ -540,6 +547,7 @@ private static int AnimateDocument(int serial, uint pDoc_serial, double dPos, In } internal static SETDOCBUFFERBUFFERBBOXPROC extendboundingboxfordocumentanimation_proc = ExtendBoundingBoxForDocumentAnimation; + [MonoPInvokeCallback(typeof(SETDOCBUFFERBUFFERBBOXPROC))] private static void ExtendBoundingBoxForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop, ref Geometry.BoundingBox bbox) { var client = FromSerialNumber(serial); @@ -555,6 +563,7 @@ private static void ExtendBoundingBoxForDocumentAnimation(int serial, uint pDoc_ } internal static SETINTINTPROC animationstart_proc = AnimationStart; + [MonoPInvokeCallback(typeof(SETINTINTPROC))] private static void AnimationStart(int serial, uint doc_serial, int iFrames) { var client = FromSerialNumber(serial); @@ -567,6 +576,7 @@ private static void AnimationStart(int serial, uint doc_serial, int iFrames) } internal static GETBOOLDOCBUFFERBUFFERPROC preparefordocumentanimation_proc = PrepareForDocumentAnimation; + [MonoPInvokeCallback(typeof(GETBOOLDOCBUFFERBUFFERPROC))] private static int PrepareForDocumentAnimation(int serial, uint pDoc_serial, IntPtr pArchive_start, IntPtr pArchive_stop) { var client = FromSerialNumber(serial); @@ -584,6 +594,7 @@ private static int PrepareForDocumentAnimation(int serial, uint pDoc_serial, Int } internal static GETBOOLDOCOBJECTTRANSFORMBUFFERPROC objecttransformnotification_proc = ObjectTransformNotification; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJECTTRANSFORMBUFFERPROC))] private static int ObjectTransformNotification(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive) { var client = FromSerialNumber(serial); @@ -601,6 +612,7 @@ private static int ObjectTransformNotification(int serial, uint doc_serial, uint } internal static GETBOOLDOCOBJECTTRANSFORMBUFFERPROC saveobject_proc = SaveObject; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJECTTRANSFORMBUFFERPROC))] private static int SaveObject(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive) { var client = FromSerialNumber(serial); @@ -618,6 +630,7 @@ private static int SaveObject(int serial, uint doc_serial, uint obj_serial, ref } internal static GETBOOLDOCOBJECTTRANSFORMBUFFERPROC restoreobject_proc = RestoreObject; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJECTTRANSFORMBUFFERPROC))] private static int RestoreObject(int serial, uint doc_serial, uint obj_serial, ref Geometry.Transform transform, IntPtr pArchive) { var client = FromSerialNumber(serial); @@ -635,6 +648,7 @@ private static int RestoreObject(int serial, uint doc_serial, uint obj_serial, r } internal static SETINTINT snapshotrestored_proc = SnapshotRestored; + [MonoPInvokeCallback(typeof(SETINTINT))] private static void SnapshotRestored(int serial, uint doc_serial) { var client = FromSerialNumber(serial); @@ -648,6 +662,7 @@ private static void SnapshotRestored(int serial, uint doc_serial) } internal static GETBOOLOBJECTPROC supportsobject_proc = SupportsObject; + [MonoPInvokeCallback(typeof(GETBOOLOBJECTPROC))] private static int SupportsObject(int serial, uint obj_serial) { var client = FromSerialNumber(serial); @@ -663,6 +678,7 @@ private static int SupportsObject(int serial, uint obj_serial) } internal static GETBOOLDOCBUFFERPROC restoredocument_proc = RestoreDocument; + [MonoPInvokeCallback(typeof(GETBOOLDOCBUFFERPROC))] private static int RestoreDocument(int serial, uint doc_serial, IntPtr pArchive) { var client = FromSerialNumber(serial); @@ -678,6 +694,7 @@ private static int RestoreDocument(int serial, uint doc_serial, IntPtr pArchive) } internal static GETBOOLDOCBUFFERPROC savedocument_proc = SaveDocument; + [MonoPInvokeCallback(typeof(GETBOOLDOCBUFFERPROC))] private static int SaveDocument(int serial, uint doc_serial, IntPtr pArchive) { var client = FromSerialNumber(serial); @@ -693,6 +710,7 @@ private static int SaveDocument(int serial, uint doc_serial, IntPtr pArchive) } internal static GETSTRINGPROC gategory_proc = Category; + [MonoPInvokeCallback(typeof(GETSTRINGPROC))] private static void Category(int serial, IntPtr pON_wString) { var client = FromSerialNumber(serial); @@ -705,6 +723,7 @@ private static void Category(int serial, IntPtr pON_wString) } internal static GETBOOLPROC supportsdoc_proc = SupportsDocument; + [MonoPInvokeCallback(typeof(GETBOOLPROC))] private static int SupportsDocument(int serial) { var client = FromSerialNumber(serial); @@ -718,6 +737,7 @@ private static int SupportsDocument(int serial) } internal static GETBOOLPROC supportsanimation_proc = SupportsAnimation; + [MonoPInvokeCallback(typeof(GETBOOLPROC))] private static int SupportsAnimation(int serial) { var client = FromSerialNumber(serial); @@ -731,6 +751,7 @@ private static int SupportsAnimation(int serial) } internal static GETBOOLPROC supportsobjects_proc = SupportsObjects; + [MonoPInvokeCallback(typeof(GETBOOLPROC))] private static int SupportsObjects(int serial) { var client = FromSerialNumber(serial); @@ -744,6 +765,7 @@ private static int SupportsObjects(int serial) } internal static GETSTRINGPROC name_proc = Name; + [MonoPInvokeCallback(typeof(GETSTRINGPROC))] private static void Name(int serial, IntPtr pON_wString) { var client = FromSerialNumber(serial); @@ -756,6 +778,7 @@ private static void Name(int serial, IntPtr pON_wString) } internal static GETBOOLDOCBUFFERBUFFERARRAYTEXTLOGPROC iscurrentmodelstateinanysnapshot_proc = IsCurrentModelStateInAnySnapshot; + [MonoPInvokeCallback(typeof(GETBOOLDOCBUFFERBUFFERARRAYTEXTLOGPROC))] private static int IsCurrentModelStateInAnySnapshot(int serial, uint pDoc_serial, IntPtr pArchive, IntPtr pArchives, IntPtr pTextLog) { var client = FromSerialNumber(serial); @@ -777,6 +800,7 @@ private static int IsCurrentModelStateInAnySnapshot(int serial, uint pDoc_serial } internal static GETBOOLDOCOBJBUFFERBUFFERARRAYTEXTLOGPROC iscurrentobjmodelstateinanysnapshot_proc = IsCurrentObjModelStateInAnySnapshot; + [MonoPInvokeCallback(typeof(GETBOOLDOCOBJBUFFERBUFFERARRAYTEXTLOGPROC))] private static int IsCurrentObjModelStateInAnySnapshot(int serial, uint pDoc_serial, uint obj_serial, IntPtr pArchive, IntPtr pArchives, IntPtr pTextLog) { var client = FromSerialNumber(serial); diff --git a/src/dotnet/rhino/rhinosdkstackeddialogpage.cs b/src/dotnet/rhino/rhinosdkstackeddialogpage.cs index 1a33d9f75..e3829aebc 100644 --- a/src/dotnet/rhino/rhinosdkstackeddialogpage.cs +++ b/src/dotnet/rhino/rhinosdkstackeddialogpage.cs @@ -45,12 +45,14 @@ public interface IStackedDialogPageService /// /// /// + /// 8.3 bool SetNativeParent(IntPtr hwndParent, object host); /// /// Gets the native window handle associated with the host object if there is one. /// /// /// + /// 8.4 IntPtr NativeHandle(object host); /// /// Get the unmanaged pointer associated with the pages content control diff --git a/src/dotnet/rhino/rhinosdkview.cs b/src/dotnet/rhino/rhinosdkview.cs index c95e7f0e0..bbcf22406 100644 --- a/src/dotnet/rhino/rhinosdkview.cs +++ b/src/dotnet/rhino/rhinosdkview.cs @@ -1,6 +1,7 @@ #pragma warning disable 1591 using System; using Rhino.Render; +using Rhino.Runtime; #if RHINO_SDK @@ -209,6 +210,7 @@ public static bool EnableDrawing /// /// true if the view is being dynamically changed by mouse moves, arrow keys, trackballs, etc. /// + /// 8.1 public bool InDynamicViewChange { get @@ -1302,6 +1304,52 @@ public RhinoPageView PageView /// 5.0 public Guid OldActiveDetailId { get; private set; } } + + /// + /// PageView properties change event arguments. + /// + /// 8.9 + public class PageViewPropertiesChangeEventArgs : EventArgs + { + internal PageViewPropertiesChangeEventArgs(uint documentSerialNumber, uint pageViewSerialNumber) + { + DocumentSerialNumber = documentSerialNumber; + PageViewSerialNumber = pageViewSerialNumber; + } + + /// + /// The serial number of the Rhino document. + /// + /// 8.9 + [CLSCompliant(false)] + public uint DocumentSerialNumber { get; private set; } + + /// + /// The serial number of the page view. + /// + /// 8.9 + [CLSCompliant(false)] + public uint PageViewSerialNumber { get; private set; } + + /// + /// Gets the Rhino document. + /// + /// 8.9 + public RhinoDoc Document => RhinoDoc.FromRuntimeSerialNumber(DocumentSerialNumber); + + /// + /// Gets the Rhino page view. + /// + /// 8.9 + public RhinoPageView PageView + { + get + { + var view = RhinoView.FromRuntimeSerialNumber(PageViewSerialNumber); + return view is RhinoPageView pageView ? pageView : null; + } + } + } } #endif diff --git a/src/dotnet/rhino/rhinosdkviewport.cs b/src/dotnet/rhino/rhinosdkviewport.cs index a368c2fe3..079081d8d 100644 --- a/src/dotnet/rhino/rhinosdkviewport.cs +++ b/src/dotnet/rhino/rhinosdkviewport.cs @@ -22,6 +22,19 @@ public enum DefinedViewportProjection TwoPointPerspective = 8 } + /// + /// Isometric camera orientation. + /// + /// 8.10 + public enum IsometricCamera + { + None = 0, + Northeast = 1, + Northwest = 2, + Southeast = 3, + Southwest = 4, + } + #if RHINO_SDK /// /// Displays geometry with a given projection. In standard modeling views there diff --git a/src/librhino3dm_native/on_3dm_attributes.cpp b/src/librhino3dm_native/on_3dm_attributes.cpp index 994deeaf7..56c84cd8d 100644 --- a/src/librhino3dm_native/on_3dm_attributes.cpp +++ b/src/librhino3dm_native/on_3dm_attributes.cpp @@ -375,6 +375,14 @@ RH_C_FUNCTION void ON_3dmObjectAttributes_GroupList(const ON_3dmObjectAttributes } } +RH_C_FUNCTION bool ON_3dmObjectAttributes_IsInGroup(const ON_3dmObjectAttributes* ptr, int index) +{ + if (ptr) + return ptr->IsInGroup(index); + + return false; +} + RH_C_FUNCTION void ON_3dmObjectAttributes_GroupOp(ON_3dmObjectAttributes* ptr, int whichOp, int index) { if( NULL == ptr ) diff --git a/src/librhino3dm_native/on_3dm_settings.cpp b/src/librhino3dm_native/on_3dm_settings.cpp index d8e1b3712..bc4d670dd 100644 --- a/src/librhino3dm_native/on_3dm_settings.cpp +++ b/src/librhino3dm_native/on_3dm_settings.cpp @@ -1,5 +1,55 @@ #include "stdafx.h" +RH_C_FUNCTION ON_3dmConstructionPlaneGridDefaults* ON_3dmConstructionPlaneGridDefaults_New() +{ + return new ON_3dmConstructionPlaneGridDefaults(); +} + +RH_C_FUNCTION void ON_3dmConstructionPlaneGridDefaults_Delete(ON_3dmConstructionPlaneGridDefaults* gridDefaults) +{ + if (gridDefaults) + delete gridDefaults; +} + +RH_C_FUNCTION void ON_3dmConstructionPlaneGridDefaults_Get(const ON_3dmConstructionPlaneGridDefaults* defaults, + double* gridSpacing, double* snapSpacing, + int* gridLineCount, int* gridThickFrequency, + bool* showGrid, bool* showGridAxes, bool* showWorldAxes) +{ + if (nullptr == defaults) + return; + if (gridSpacing) + *gridSpacing = defaults->m_grid_spacing; + if (snapSpacing) + *snapSpacing = defaults->m_snap_spacing; + if (gridLineCount) + *gridLineCount = defaults->m_grid_line_count; + if (gridThickFrequency) + *gridThickFrequency = defaults->m_grid_thick_frequency; + if (showGrid) + *showGrid = defaults->m_bShowGrid; + if (showGridAxes) + *showGridAxes = defaults->m_bShowGridAxes; + if (showWorldAxes) + *showWorldAxes = defaults->m_bShowWorldAxes; +} + +RH_C_FUNCTION void ON_3dmConstructionPlaneGridDefaults_Set(ON_3dmConstructionPlaneGridDefaults* defaults, + double gridSpacing, double snapSpacing, + int gridLineCount, int gridThickFrequency, + bool showGrid, bool showGridAxes, bool showWorldAxes) +{ + if (nullptr == defaults) + return; + defaults->m_grid_spacing = gridSpacing; + defaults->m_snap_spacing = snapSpacing; + defaults->m_grid_line_count = gridLineCount; + defaults->m_grid_thick_frequency = gridThickFrequency; + defaults->m_bShowGrid = showGrid; + defaults->m_bShowGridAxes = showGridAxes; + defaults->m_bShowWorldAxes = showWorldAxes; +} + RH_C_FUNCTION void ON_3dmConstructionPlane_Copy(const ON_3dmConstructionPlane* pCP, ON_PLANE_STRUCT* plane, double* grid_spacing, double* snap_spacing, int* grid_line_count, int* grid_thick_freq, diff --git a/src/librhino3dm_native/on_arc.cpp b/src/librhino3dm_native/on_arc.cpp index 102723d7c..cd5f1733f 100644 --- a/src/librhino3dm_native/on_arc.cpp +++ b/src/librhino3dm_native/on_arc.cpp @@ -62,7 +62,7 @@ RH_C_FUNCTION bool ON_Arc_IsValid(ON_Arc* pArc) if( pArc ) { pArc->plane.UpdateEquation(); - rc = pArc->IsValid() ? true : false; + rc = pArc->IsValid(); } return rc; } diff --git a/src/librhino3dm_native/on_brep.cpp b/src/librhino3dm_native/on_brep.cpp index e59944c04..23fb6a3a9 100644 --- a/src/librhino3dm_native/on_brep.cpp +++ b/src/librhino3dm_native/on_brep.cpp @@ -574,7 +574,7 @@ RH_C_FUNCTION void ON_Brep_DuplicateEdgeCurves(const ON_Brep* pConstBrep, ON_Sim { // From RhinoScript: // make the curve direction go in the natural boundary loop direction - // so that the curve directions come out consistantly + // so that the curve directions come out consistently // 16-Mar-2016 Dale Fugier, validate trim count if (edge.TrimCount()) diff --git a/src/librhino3dm_native/on_curve.cpp b/src/librhino3dm_native/on_curve.cpp index d1af745a8..a8f4e710d 100644 --- a/src/librhino3dm_native/on_curve.cpp +++ b/src/librhino3dm_native/on_curve.cpp @@ -836,4 +836,21 @@ RH_C_FUNCTION bool ONC_CombineShortSegments(ON_Curve* ptrCurve, double tolerance return ON_CombineShortSegments(*ptrCurve, tolerance); return false; } + +RH_C_FUNCTION bool RHC_RhExtractCurveControlPolygon(const ON_Curve* pCurve, ON_Polyline* pPolyline) +{ + bool rc = false; + if (pCurve && pPolyline) + rc = RhExtractCurveControlPolygon(pCurve, *pPolyline); + return rc; +} + +RH_C_FUNCTION void ONC_SpanVector(const ON_Curve* curve, ON_SimpleArray* vector) +{ + if (vector) vector->Empty(); + if (curve) + { + *vector = curve->SpanVector(); + } +} #endif diff --git a/src/librhino3dm_native/on_defines.cpp b/src/librhino3dm_native/on_defines.cpp index 43d1b93bf..6fcac040c 100644 --- a/src/librhino3dm_native/on_defines.cpp +++ b/src/librhino3dm_native/on_defines.cpp @@ -62,7 +62,7 @@ RH_C_FUNCTION const RHMONO_STRING* ON_wString_Get(ON_wString* pString, CRhCmnStr const RHMONO_STRING* rc = nullptr; if (pString) { -#if defined (_WIN32) +#if defined (ON_RUNTIME_WIN) UNREFERENCED_PARAMETER(stringHolder); rc = pString->Array(); #endif diff --git a/src/librhino3dm_native/on_hiddenlinedrawing.cpp b/src/librhino3dm_native/on_hiddenlinedrawing.cpp index 6e4cb82ac..fdc616a35 100644 --- a/src/librhino3dm_native/on_hiddenlinedrawing.cpp +++ b/src/librhino3dm_native/on_hiddenlinedrawing.cpp @@ -167,6 +167,9 @@ RH_C_FUNCTION void ON_HiddenLineDrawing_EnableObjOccludingSection(ON_HiddenLineD RH_C_FUNCTION bool ON_HiddenLineDrawing_EnableSelectiveClipping(ON_HiddenLineDrawing* pHiddenLineDrawing, int obj_ind, const ON_SimpleArray* active_clip_ids ) { + if (nullptr==pHiddenLineDrawing || nullptr==active_clip_ids) + return false; + bool rc = false; ON_SimpleArray< ON__UINT_PTR> Arr2(ON_HiddenLineDrawing::PerspectiveViewClipCount + active_clip_ids->Count()); @@ -179,7 +182,7 @@ RH_C_FUNCTION bool ON_HiddenLineDrawing_EnableSelectiveClipping(ON_HiddenLineDra for (int i = 0; i < active_clip_ids->Count(); i++) Arr2.Append((*active_clip_ids)[i]); - if (pHiddenLineDrawing && obj_ind>=0 && obj_ind< pHiddenLineDrawing->m_object.Count() && active_clip_ids) + if (obj_ind>=0 && obj_ind< pHiddenLineDrawing->m_object.Count()) { const ON_HLD_Object* cobj = pHiddenLineDrawing->m_object[obj_ind]; ON_HLD_Object* obj = const_cast(cobj); diff --git a/src/librhino3dm_native/on_light.cpp b/src/librhino3dm_native/on_light.cpp index 88be8f560..93c8a9f31 100644 --- a/src/librhino3dm_native/on_light.cpp +++ b/src/librhino3dm_native/on_light.cpp @@ -9,7 +9,7 @@ RH_C_FUNCTION bool ON_Light_IsEnabled(const ON_Light* pConstLight) { bool rc = false; if( pConstLight ) - rc = pConstLight->IsEnabled()?true:false; + rc = pConstLight->IsEnabled(); return rc; } diff --git a/src/librhino3dm_native/on_massprop.cpp b/src/librhino3dm_native/on_massprop.cpp index ffd39ff00..7b757166b 100644 --- a/src/librhino3dm_native/on_massprop.cpp +++ b/src/librhino3dm_native/on_massprop.cpp @@ -68,6 +68,14 @@ RH_C_FUNCTION bool ON_MassProperties_Sum(ON_MassProperties* pMassProp, ON_MassPr return rc; } +RH_C_FUNCTION bool ON_MassProperties_Transform(ON_MassProperties* pMassProp, ON_Xform* pXform) +{ + bool rc = false; + if (pMassProp && pXform && pXform->IsValid()) + rc = pMassProp->Transform(*pXform); + return rc; +} + RH_C_FUNCTION bool ON_MassProperties_GetMoments(const ON_MassProperties* pConstMassProps, int which, ON_3dVector* moment, ON_3dVector* error ) { const int idx_wc_firstmoments = 0; diff --git a/src/librhino3dm_native/on_material.cpp b/src/librhino3dm_native/on_material.cpp index c47d18c4c..de0a28e93 100644 --- a/src/librhino3dm_native/on_material.cpp +++ b/src/librhino3dm_native/on_material.cpp @@ -777,21 +777,21 @@ enum class TextureProjectionModes : int Wcs = 3, /// Box type world coordinate system projection WcsBox = 4, - /// Box type environtment mapping + /// Box type environment mapping EnvironmentMapBox = 5, - /// Light probe type environtment mapping + /// Light probe type environment mapping EnvironmentMapLightProbe = 6, - /// Spherical environtment mapping + /// Spherical environment mapping EnvironmentMapSpherical = 7, - /// Cube type environtment mapping + /// Cube type environment mapping EnvironmentMapCube = 8, - /// Vertical cross cube type environtment mapping + /// Vertical cross cube type environment mapping EnvironmentMapVCrossCube = 9, - /// Horizontal cross type environtment mapping + /// Horizontal cross type environment mapping EnvironmentMapHCrossCube = 10, - /// Hemispherical environtment mapping + /// Hemispherical environment mapping EnvironmentMapHemispherical = 11, - /// Emap type environtment mapping + /// Emap type environment mapping EnvironmentMapEmap = 12, /// Surface parameterization SurfaceParameterization = 13, diff --git a/src/librhino3dm_native/rhcommon_c/rhcommon_c_api.h b/src/librhino3dm_native/rhcommon_c/rhcommon_c_api.h index 6fc45e439..1382f0dee 100644 --- a/src/librhino3dm_native/rhcommon_c/rhcommon_c_api.h +++ b/src/librhino3dm_native/rhcommon_c/rhcommon_c_api.h @@ -124,7 +124,7 @@ _variablename = (LPCTSTR) _variablename##_; \ // Android compile -#if defined (ON_COMPILER_ANDROIDNDK) || defined(ON_RUNTIME_LINUX) +#if defined (ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) #define RH_CPP_FUNCTION __attribute__ ((visibility ("default"))) #define RH_CPP_CLASS __attribute__ ((visibility ("default"))) #define RH_C_FUNCTION extern "C" __attribute__ ((visibility ("default"))) @@ -152,7 +152,7 @@ typedef signed char BOOL; #define TRUE 1 #define FALSE 0 #define CALLBACK -#endif // ON_COMPILER_ANDROIDNDK +#endif // Only applicable for when compiled for running inside Rhino #if !defined(RHINO3DM_BUILD) @@ -256,7 +256,7 @@ class RH_EXPORT CRhCmnStringHolder #else ON_wString m_winString; #endif -#if defined(ON_COMPILER_ANDROIDNDK) || defined(ON_RUNTIME_LINUX) +#if defined(ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) ON_SimpleArray m_android; #endif }; From 5dcfc8d211673db5604b660ebbb4597b977bf3b3 Mon Sep 17 00:00:00 2001 From: fraguada Date: Tue, 26 Nov 2024 11:24:42 +0100 Subject: [PATCH 2/7] more sync --- src/librhino3dm_native/on_mesh.cpp | 2 +- src/librhino3dm_native/on_planesurface.cpp | 16 +++++ src/librhino3dm_native/on_subd.cpp | 19 ++++++ src/librhino3dm_native/on_sun.cpp | 71 +++++++++++----------- src/librhino3dm_native/on_text.cpp | 17 ++++-- src/librhino3dm_native/on_userdata.cpp | 19 ------ src/librhino3dm_native/on_viewport.cpp | 4 +- src/librhino3dm_native/stringholder.cpp | 2 +- 8 files changed, 87 insertions(+), 63 deletions(-) diff --git a/src/librhino3dm_native/on_mesh.cpp b/src/librhino3dm_native/on_mesh.cpp index 95586c53e..9dd30af83 100644 --- a/src/librhino3dm_native/on_mesh.cpp +++ b/src/librhino3dm_native/on_mesh.cpp @@ -4049,7 +4049,7 @@ RH_C_FUNCTION int ON_Mesh_GetNgonBoundaryPoints( for (i = 0; ict > i; i++) ngon_boundary_points->Append(constMesh->Vertex(verts[i])); } - if (true == bAppendStartPoint) + if (bAppendStartPoint) ngon_boundary_points->Append(constMesh->Vertex(verts[0])); } diff --git a/src/librhino3dm_native/on_planesurface.cpp b/src/librhino3dm_native/on_planesurface.cpp index c387c8411..9bba8a040 100644 --- a/src/librhino3dm_native/on_planesurface.cpp +++ b/src/librhino3dm_native/on_planesurface.cpp @@ -267,3 +267,19 @@ RH_C_FUNCTION void ON_ClippingPlaneSurface_ClearParticipationLists(ON_ClippingPl pClippingPlaneSurface->m_clipping_plane.SetParticipationLists(nullptr, nullptr, true); } } + +RH_C_FUNCTION ON_ClippingPlaneSurface* ON_ClippingPlaneSurface_New() +{ + return new ON_ClippingPlaneSurface(); +} + +RH_C_FUNCTION ON_ClippingPlaneSurface* ON_ClippingPlaneSurface_New_FromPlane(const ON_PLANE_STRUCT* plane ) +{ + ON_Plane temp = FromPlaneStruct(*plane); + return new ON_ClippingPlaneSurface(temp); +} + +RH_C_FUNCTION ON_ClippingPlaneSurface* ON_ClippingPlaneSurface_New_FromPLaneSurface(const ON_PlaneSurface* planeSurface) +{ + return new ON_ClippingPlaneSurface(*planeSurface); +} diff --git a/src/librhino3dm_native/on_subd.cpp b/src/librhino3dm_native/on_subd.cpp index 5c7c93a9e..90d482499 100644 --- a/src/librhino3dm_native/on_subd.cpp +++ b/src/librhino3dm_native/on_subd.cpp @@ -397,6 +397,13 @@ RH_C_FUNCTION unsigned int ON_SubD_ConstUpdateSurfaceMeshCache(const ON_SubD* co return 0U; } +RH_C_FUNCTION bool ON_SubD_SurfaceMeshCacheExists(const ON_SubD* constSubdPtr, bool bTextureCoordinatesExist, bool bCurvaturesExist, bool bColorsExist) +{ + if (constSubdPtr) + return constSubdPtr->SurfaceMeshCacheExists(bTextureCoordinatesExist, bCurvaturesExist, bColorsExist); + return false; +} + RH_C_FUNCTION ON_Mesh* ON_SubD_ToLimitSurfaceMesh( const ON_SubD* constSubdPtr, unsigned int mesh_density ) { RHCHECK_LICENSE @@ -1002,6 +1009,18 @@ RH_C_FUNCTION void ON_SubD_ConstDuplicateEdgeCurves(const ON_SubD* pSubD, ON_Sim { return ON_SubD_DuplicateEdgeCurves(const_cast(pSubD), pOutCurves, boundaryOnly, interiorOnly, smoothOnly, sharpOnly, creaseOnly, clampEnds); } + +RH_C_FUNCTION unsigned int ON_SubD_TransformComponents(ON_SubD* pSubD, const ON_Xform* pXform, int componentCount, /*ARRAY*/const ON_COMPONENT_INDEX* pComponents, ON_SubDComponentLocation componentLocation) +{ + // https://mcneel.myjetbrains.com/youtrack/issue/RH-83674 + unsigned int rc = 0; + if (pSubD && pXform && pComponents) + { + rc = pSubD->TransformComponents(*pXform, pComponents, (size_t)componentCount, componentLocation); + } + return rc; +} + #endif ///////////////////// ON_SubDFace diff --git a/src/librhino3dm_native/on_sun.cpp b/src/librhino3dm_native/on_sun.cpp index 5d6f421a8..9ce1b7c45 100644 --- a/src/librhino3dm_native/on_sun.cpp +++ b/src/librhino3dm_native/on_sun.cpp @@ -1,40 +1,18 @@ #include "stdafx.h" -static double DecimalHoursFromHMS(int iHour, int iMinute, int iSecond) +static time_t TimeFromYMDH(int year, int month, int day, double dh) { - return iHour + (iMinute / 60.0) + (iSecond / 3600.0); -} - -static void DecimalHoursToHMS(double dHours, int& iHour, int& iMinute, int& iSecond) -{ - while (dHours >= 24.0) - dHours -= 24.0; - - while (dHours < 0.0) - dHours += 24.0; - - iHour = (int)dHours; - - const double dMinute = (dHours - iHour) * 60.0; - iMinute = (int)dMinute; - - const double dSecond = (dMinute - iMinute) * 60.0; - iSecond = (int)dSecond; -} - -static time_t TimeFromYMDH(int y, int m, int d, double dh) -{ - int h = 0, n = 0, s = 0; - DecimalHoursToHMS(dh, h, n, s); + int hour = 0, minute = 0, second = 0; + ON_DecimalHoursToHMS(dh, hour, minute, second, year, month, day); tm ttm = { 0 }; - ttm.tm_sec = s; - ttm.tm_min = n; - ttm.tm_hour = h; - ttm.tm_mday = d; - ttm.tm_mon = m - 1; - ttm.tm_year = y - 1900; + ttm.tm_sec = second; + ttm.tm_min = minute; + ttm.tm_hour = hour; + ttm.tm_mday = day; + ttm.tm_mon = month - 1; + ttm.tm_year = year - 1900; ttm.tm_isdst = -1; return mktime(&ttm); } @@ -54,17 +32,17 @@ static void GetYMDH(const ON_XMLVariant& v, int& y, int& m, int& d, double& h) y = ttm.tm_year + 1900; m = ttm.tm_mon + 1; d = ttm.tm_mday; - h = DecimalHoursFromHMS(ttm.tm_hour, ttm.tm_min, ttm.tm_sec); + h = ON_DecimalHoursFromHMS(ttm.tm_hour, ttm.tm_min, ttm.tm_sec); } static time_t TimeFromSun(const ON_Sun& sun, bool local) { - int y = 0, m = 0, d = 0; double dh = 0.0; + int year = 0, month = 0, day = 0; double hours = 0.0; - if (local) sun.LocalDateTime(y, m, d, dh); - else sun.UTCDateTime (y, m, d, dh); + if (local) sun.LocalDateTime(year, month, day, hours); + else sun.UTCDateTime (year, month, day, hours); - return TimeFromYMDH(y, m, d, dh); + return TimeFromYMDH(year, month, day, hours); } enum class SunSetting : int @@ -246,3 +224,24 @@ RH_C_FUNCTION double GetSunJulianDay(double timeZoneHours, int daylightMinutes, return engine.JulianDay(); } + +RH_C_FUNCTION double DecimalHoursFromHMS(int h, int m, int s) +{ + return ON_DecimalHoursFromHMS(h, m, s); +} + +RH_C_FUNCTION void DecimalHoursToHMS(double hours, int* hour, int* min, int* sec) +{ + if (hour && min && sec) + { + ON_DecimalHoursToHMS(hours, *hour, *min, *sec); + } +} + +RH_C_FUNCTION void DecimalHoursToHMSWithDate(double hours, int* hour, int* min, int* sec, int* year, int* month, int* day) +{ + if (hour && min && sec && year && month && day) + { + ON_DecimalHoursToHMS(hours, *hour, *min, *sec, *year, *month, *day); + } +} diff --git a/src/librhino3dm_native/on_text.cpp b/src/librhino3dm_native/on_text.cpp index 9677dfdbf..9dadbd0d1 100644 --- a/src/librhino3dm_native/on_text.cpp +++ b/src/librhino3dm_native/on_text.cpp @@ -470,7 +470,10 @@ RH_C_FUNCTION void ON_V6_Annotation_SetAlternateLengthResolution(ON_Annotation* RH_C_FUNCTION void ON_V6_Annotation_Prefix(const ON_Annotation* annotation, const ON_DimStyle* parent_style, ON_wString* wstring) { - if (nullptr != annotation && nullptr != wstring) + if (nullptr == wstring) + return; + + if (nullptr != annotation) *wstring = annotation->Prefix(parent_style); else *wstring = ON_wString::EmptyString; @@ -487,7 +490,10 @@ RH_C_FUNCTION void ON_V6_Annotation_SetPrefix(ON_Annotation* annotation, const O RH_C_FUNCTION void ON_V6_Annotation_Suffix(const ON_Annotation* annotation, const ON_DimStyle* parent_style, ON_wString* wstring) { - if (nullptr != annotation && nullptr != wstring) + if (nullptr == wstring) + return; + + if (nullptr != annotation) *wstring = annotation->Suffix(parent_style); else *wstring = ON_wString::EmptyString; @@ -504,7 +510,10 @@ RH_C_FUNCTION void ON_V6_Annotation_SetSuffix(ON_Annotation* annotation, const O RH_C_FUNCTION void ON_V6_Annotation_AlternatePrefix(const ON_Annotation* annotation, const ON_DimStyle* parent_style, ON_wString* wstring) { - if (nullptr != annotation && nullptr != wstring) + if (nullptr == wstring) + return; + + if (nullptr != annotation) *wstring = annotation->AlternatePrefix(parent_style); else *wstring = ON_wString::EmptyString; @@ -1641,7 +1650,7 @@ RH_C_FUNCTION bool ON_V6_TextObject_GetTextXform(const ON_Text* constPtrTextObje bool rc = false; if (constPtrTextObject && xform_out) { - rc = constPtrTextObject->GetTextXform(nullptr, dimstyle, scale, *xform_out) ? true : false; + rc = constPtrTextObject->GetTextXform(nullptr, dimstyle, scale, *xform_out); } return rc; } diff --git a/src/librhino3dm_native/on_userdata.cpp b/src/librhino3dm_native/on_userdata.cpp index a38cc0184..77e77700b 100644 --- a/src/librhino3dm_native/on_userdata.cpp +++ b/src/librhino3dm_native/on_userdata.cpp @@ -194,26 +194,7 @@ static CRhCmnClassIdList g_classIds; const CRhCmnUserData* CRhCmnUserData::Cast( const ON_Object* p ) { - // The only reason I'm using an #if block below instead of always - // using the androidndk approach is because this code is going into - // Rhino5 SR code and I don't want to risk any chance of breaking - // anything. -#if defined (ON_COMPILER_ANDROIDNDK) - // typical android NDK builds do not include support for the overhead - // of dynamic_cast. Just dig through the list of already created class - // ids for the rhino common user data classes. - if( p ) - { - for( int i=0; iIsKindOf(pClassId) ) - return static_cast(p); - } - } -#else return dynamic_cast(p); -#endif } diff --git a/src/librhino3dm_native/on_viewport.cpp b/src/librhino3dm_native/on_viewport.cpp index 45c532588..7816b80c0 100644 --- a/src/librhino3dm_native/on_viewport.cpp +++ b/src/librhino3dm_native/on_viewport.cpp @@ -31,7 +31,7 @@ RH_C_FUNCTION bool ON_Viewport_GetBool(const ON_Viewport* pConstViewport, int wh rc = pConstViewport->IsValidFrustum(); break; case idxIsValid: - rc = pConstViewport->IsValid()?true:false; + rc = pConstViewport->IsValid(); break; case idxIsPerspectiveProjection: rc = pConstViewport->IsPerspectiveProjection(); @@ -742,7 +742,7 @@ RH_C_FUNCTION bool ON_Viewport_DollyExtents(ON_Viewport* pViewport, ON_3DPOINT_S double zmin = camcoord_bbox.m_min.z; double zmax = camcoord_bbox.m_max.z; - // Please discuss any changes to dz caclulations with Dale Lear + // Please discuss any changes to dz calculations with Dale Lear // before you check in the code. double dz = (zmax - zmin)*0.00390625; // 0.00390625 = 1/256 if ( ON::perspective_view == pViewport->Projection() ) diff --git a/src/librhino3dm_native/stringholder.cpp b/src/librhino3dm_native/stringholder.cpp index 81166db2d..d1e0288a0 100644 --- a/src/librhino3dm_native/stringholder.cpp +++ b/src/librhino3dm_native/stringholder.cpp @@ -67,7 +67,7 @@ const RHMONO_STRING* CRhCmnStringHolder::Array() const return m_macString; #endif -#if defined (ON_COMPILER_ANDROIDNDK) || defined(ON_RUNTIME_LINUX) +#if defined (ON_RUNTIME_ANDROID) || defined(ON_RUNTIME_LINUX) const ON__UINT32* sUTF32 = (const ON__UINT32*)m_winString.Array(); int length = m_winString.Length(); CRhCmnStringHolder* pThis = const_cast(this); From 6605e537dadd4122b7babe4d51d3d717bdbcfa24 Mon Sep 17 00:00:00 2001 From: fraguada Date: Fri, 29 Nov 2024 11:25:53 +0100 Subject: [PATCH 3/7] more sync --- src/lib/opennurbs | 2 +- src/librhino3dm_native/on_3dm_attributes.cpp | 4 + src/librhino3dm_native/on_curve.cpp | 37 +++++- src/librhino3dm_native/on_defines.cpp | 10 +- src/librhino3dm_native/on_hatch.cpp | 2 + src/librhino3dm_native/on_math.cpp | 48 ++++++++ src/librhino3dm_native/on_mesh.cpp | 41 +++++++ src/librhino3dm_native/on_subd.cpp | 1 + src/librhino3dm_native/on_viewport.cpp | 119 ++----------------- 9 files changed, 139 insertions(+), 125 deletions(-) diff --git a/src/lib/opennurbs b/src/lib/opennurbs index b02292b11..c90148184 160000 --- a/src/lib/opennurbs +++ b/src/lib/opennurbs @@ -1 +1 @@ -Subproject commit b02292b1190dc2e1822f97d6fbdfbc9ff3f52a5d +Subproject commit c901481840e41634db7eb07ff2924c17fe94fbb8 diff --git a/src/librhino3dm_native/on_3dm_attributes.cpp b/src/librhino3dm_native/on_3dm_attributes.cpp index 56c84cd8d..e5093c49a 100644 --- a/src/librhino3dm_native/on_3dm_attributes.cpp +++ b/src/librhino3dm_native/on_3dm_attributes.cpp @@ -644,6 +644,7 @@ enum DisplayModeSpecialType : int dmstPen = 8, dmstAmbientOcclusion = 9, dmstRaytraced = 10, + dmstMonochrome = 11 }; RH_C_FUNCTION ON_UUID ON_MaterialRef_DisplayModeSpecialType(const DisplayModeSpecialType displayModeSpecialType) @@ -685,6 +686,9 @@ RH_C_FUNCTION ON_UUID ON_MaterialRef_DisplayModeSpecialType(const DisplayModeSpe case dmstRaytraced: id = CRhinoDisplayAttrsMgr::RaytracedModeId(); break; + case dmstMonochrome: + id = CRhinoDisplayAttrsMgr::MonochromeModeId(); + break; default: id = ON_UUID(); } diff --git a/src/librhino3dm_native/on_curve.cpp b/src/librhino3dm_native/on_curve.cpp index a8f4e710d..66d591be2 100644 --- a/src/librhino3dm_native/on_curve.cpp +++ b/src/librhino3dm_native/on_curve.cpp @@ -275,20 +275,32 @@ RH_C_FUNCTION bool ON_Curve_SetPoint( ON_Curve* pCurve, ON_3DPOINT_STRUCT pt, bo return rc; } -RH_C_FUNCTION void ON_Curve_PointAt( const ON_Curve* pCurve, double t, ON_3dPoint* pt, int which ) +RH_C_FUNCTION void ON_Curve_PointAt(const ON_Curve* pCurve, double t, ON_3dPoint* pt, int which) { RHCHECK_LICENSE const int idxPointAtT = 0; const int idxPointAtStart = 1; const int idxPointAtEnd = 2; - if( pCurve && pt ) + const int idxPointAtMid = 3; + if (pCurve && pt) { - if( idxPointAtT == which ) + *pt = ON_3dPoint::UnsetPoint; + if (idxPointAtT == which) *pt = pCurve->PointAt(t); - else if( idxPointAtStart == which ) + else if (idxPointAtStart == which) *pt = pCurve->PointAtStart(); - else if( idxPointAtEnd == which ) + else if (idxPointAtEnd == which) *pt = pCurve->PointAtEnd(); + else if (idxPointAtMid == which) + { +#if defined(RHINO3DM_BUILD) + return; +#else + double s = 0.0; + if (pCurve->GetNormalizedArcLengthPoint(0.5, &s)) + *pt = pCurve->PointAt(s); +#endif + } } } @@ -352,6 +364,14 @@ RH_C_FUNCTION bool ON_Curve_FrameAt( const ON_Curve* pConstCurve, double t, ON_P // not currently available in stand alone OpenNURBS build #if !defined(RHINO3DM_BUILD) +RH_C_FUNCTION ON_Curve* ON_Curve_Reparameterize(const ON_Curve* pConstCurve) +{ + ON_Curve* rc = nullptr; + if (pConstCurve) + rc = RhReparameterizeCurve(pConstCurve, ON_Interval(), true); + return rc; +} + RH_C_FUNCTION bool ON_Curve_GetClosestPoint( const ON_Curve* pCurve, ON_3DPOINT_STRUCT test_point, double* t, double maximum_distance) { RHCHECK_LICENSE @@ -764,7 +784,14 @@ RH_C_FUNCTION bool RHC_RhinoCurve2View(const ON_Curve* curve1, const ON_Curve* c } return rc; +} +RH_C_FUNCTION ON_Curve* RHC_RhCreateRevisionCloud(const ON_Curve* pConstCurve, int segmentCount, double arcAngle, bool flip) +{ + ON_Curve* rc = nullptr; + if (pConstCurve) + rc = RhCreateRevisionCloud(pConstCurve, segmentCount, arcAngle, flip); + return rc; } RH_C_FUNCTION bool RHC_CreateTextOutlines( diff --git a/src/librhino3dm_native/on_defines.cpp b/src/librhino3dm_native/on_defines.cpp index 6fcac040c..9b431efbc 100644 --- a/src/librhino3dm_native/on_defines.cpp +++ b/src/librhino3dm_native/on_defines.cpp @@ -65,15 +65,7 @@ RH_C_FUNCTION const RHMONO_STRING* ON_wString_Get(ON_wString* pString, CRhCmnStr #if defined (ON_RUNTIME_WIN) UNREFERENCED_PARAMETER(stringHolder); rc = pString->Array(); -#endif -#if defined (__APPLE__) || defined (__linux__) - if (stringHolder) - { - stringHolder->Set(*pString); - rc = stringHolder->Array(); - } -#endif -#if defined(ON_COMPILER_ANDROIDNDK) +#else if (stringHolder) { stringHolder->Set(*pString); diff --git a/src/librhino3dm_native/on_hatch.cpp b/src/librhino3dm_native/on_hatch.cpp index 564a6ad73..01667628c 100644 --- a/src/librhino3dm_native/on_hatch.cpp +++ b/src/librhino3dm_native/on_hatch.cpp @@ -2,6 +2,8 @@ RH_C_FUNCTION ON_HatchPattern* ON_HatchPattern_New() { + if (pConstHatchPattern) + return new ON_HatchPattern(*pConstHatchPattern); return new ON_HatchPattern(); } diff --git a/src/librhino3dm_native/on_math.cpp b/src/librhino3dm_native/on_math.cpp index 0c42d1da6..4d433cd90 100644 --- a/src/librhino3dm_native/on_math.cpp +++ b/src/librhino3dm_native/on_math.cpp @@ -56,3 +56,51 @@ RH_C_FUNCTION bool ONC_EvNormalPartials( } return rc; } + +typedef double (*Callback1Delegate)(ON__UINT_PTR context, int limit_direction, double t); +typedef double (*Callback2Delegate)(ON__UINT_PTR context, int limit_direction, double s, double t); + + +RH_C_FUNCTION double ON_Integrate_1D(void* func, void* context, ON_INTERVAL_STRUCT limits, double relative_tolerance, double absolute_tolerance, double* error_bound) +{ + if (context && func) + { + const ON_Interval* t = (const ON_Interval*)&limits; + return ON_Integrate((Callback1Delegate)func, (ON__UINT_PTR)context, *t, relative_tolerance, absolute_tolerance, error_bound); + } + + // DALE LEAR thinks you should return ON_DBL_QNAN if the input is bogus + return 0.0; +} + +RH_C_FUNCTION double ON_Integrate_1D_Curve(void* func, void* context, const ON_Curve* curve, double relative_tolerance, double absolute_tolerance, double* error_bound) +{ + if (curve && func && context) + return ON_Integrate(*curve, (Callback1Delegate)func, (ON__UINT_PTR)context, curve->Domain(), relative_tolerance, absolute_tolerance, error_bound); + + // DALE LEAR thinks you should return ON_DBL_QNAN if the input is bogus + return 0.0; +} + +RH_C_FUNCTION double ON_Integrate_2D(void* func, void* context, ON_INTERVAL_STRUCT limits1, ON_INTERVAL_STRUCT limits2, double relative_tolerance, double absolute_tolerance, + double* error_bound) +{ + if (context && func) + { + const ON_Interval* s = (const ON_Interval*)&limits1; + const ON_Interval* t = (const ON_Interval*)&limits2; + return ON_Integrate((Callback2Delegate)func, (ON__UINT_PTR)context, *s, *t, relative_tolerance, absolute_tolerance, error_bound); + } + + // DALE LEAR thinks you should return ON_DBL_QNAN if the input is bogus + return 0.0; +} + +RH_C_FUNCTION double ON_Integrate_2D_Surface(void* func, void* context, const ON_Surface* surface, double relative_tolerance, double absolute_tolerance, double* error_bound) +{ + if (surface && func && context) + return ON_Integrate(*surface, (Callback2Delegate)func, (ON__UINT_PTR)context, surface->Domain(0), surface->Domain(1), relative_tolerance, absolute_tolerance, error_bound); + + // DALE LEAR thinks you should return ON_DBL_QNAN if the input is bogus + return 0.0; +} diff --git a/src/librhino3dm_native/on_mesh.cpp b/src/librhino3dm_native/on_mesh.cpp index 9dd30af83..72a640a86 100644 --- a/src/librhino3dm_native/on_mesh.cpp +++ b/src/librhino3dm_native/on_mesh.cpp @@ -3070,6 +3070,47 @@ enum TextureMappingGetTransform : int gettNxyz }; +RH_C_FUNCTION bool ON_TextureMapping_GetCapped(const ON_TextureMapping* pTextureMapping) +{ + return pTextureMapping ? pTextureMapping->m_bCapped : false; +} + +RH_C_FUNCTION int ON_TextureMapping_GetProjection(const ON_TextureMapping* pTextureMapping) +{ + return pTextureMapping ? (unsigned int)pTextureMapping->m_projection : 0; +} + +RH_C_FUNCTION int ON_TextureMapping_GetTextureSpace(const ON_TextureMapping* pTextureMapping) +{ + return pTextureMapping ? (unsigned int)pTextureMapping->m_texture_space : 0; +} + +RH_C_FUNCTION void ON_TextureMapping_SetCapped(ON_TextureMapping* pTextureMapping, bool b) +{ + if (pTextureMapping) + { + pTextureMapping->m_bCapped = b; + } +} + +RH_C_FUNCTION void ON_TextureMapping_SetProjection(ON_TextureMapping* pTextureMapping, int p) +{ + if(pTextureMapping) + { + pTextureMapping->m_projection = ON_TextureMapping::ProjectionFromUnsigned((unsigned int)p); + } +} + +RH_C_FUNCTION void ON_TextureMapping_SetTextureSpace(ON_TextureMapping* pTextureMapping, int t) +{ + if (pTextureMapping) + { + pTextureMapping->m_texture_space = ON_TextureMapping::TextureSpaceFromUnsigned((unsigned int)t); + } +} + + + RH_C_FUNCTION bool ON_TextureMapping_GetTransform(const ON_TextureMapping* pTextureMapping, TextureMappingGetTransform type, ON_Xform* xformOut) { if (pTextureMapping == nullptr || xformOut == nullptr) return false; diff --git a/src/librhino3dm_native/on_subd.cpp b/src/librhino3dm_native/on_subd.cpp index 90d482499..fce1e0b66 100644 --- a/src/librhino3dm_native/on_subd.cpp +++ b/src/librhino3dm_native/on_subd.cpp @@ -2,6 +2,7 @@ RH_C_SHARED_ENUM_PARSE_FILE("../../../opennurbs/opennurbs_subd.h") + RH_C_FUNCTION ON_SubDRef* ON_SubDRef_New() { RHCHECK_LICENSE diff --git a/src/librhino3dm_native/on_viewport.cpp b/src/librhino3dm_native/on_viewport.cpp index 7816b80c0..bf3df41de 100644 --- a/src/librhino3dm_native/on_viewport.cpp +++ b/src/librhino3dm_native/on_viewport.cpp @@ -72,6 +72,11 @@ RH_C_FUNCTION bool ON_Viewport_ChangeToParallelProjection(ON_Viewport* pVP, bool return pVP ? pVP->ChangeToParallelProjection(symmetricFrustum) : false; } +RH_C_FUNCTION bool ON_Viewport_ChangeToParallelReflectedProjection(ON_Viewport* pVP) +{ + return pVP ? pVP->ChangeToParallelReflectedProjection() : false; +} + RH_C_FUNCTION bool ON_Viewport_ChangeToPerspectiveProjection(ON_Viewport* pVP, double targetDistance, bool symmetricFrustum, double lensLength) { return pVP ? pVP->ChangeToPerspectiveProjection(targetDistance, symmetricFrustum, lensLength) : false; @@ -698,118 +703,12 @@ RH_C_FUNCTION ON_Viewport* ON_Viewport_New2(const CRhinoViewport* pRhinoViewport RH_C_FUNCTION bool ON_Viewport_DollyExtents(ON_Viewport* pViewport, ON_3DPOINT_STRUCT camboxmin, ON_3DPOINT_STRUCT camboxmax) { bool rc = false; - if( pViewport ) + if (pViewport) { - ON_BoundingBox camcoord_bbox(ON_3dPoint(camboxmin.val), ON_3dPoint(camboxmax.val)); - if ( !camcoord_bbox.IsValid() || !pViewport->IsValid() ) - { - return false; - } - - double aspect = 0.0; - if ( !pViewport->GetFrustumAspect(aspect) ) - { - return false; - } - if ( !ON_IsValid(aspect) || 0.0 == aspect ) - { - return false; - } - - // 22 May 2006 Dale Lear - // I added the scale call to handle non-uniform viewport scaling - ON_3dVector scale(1.0,1.0,0.0); - pViewport->GetViewScale(&scale.x,&scale.y); - - const double xmin = camcoord_bbox.m_min.x; - const double xmax = camcoord_bbox.m_max.x; - const double ymin = camcoord_bbox.m_min.y; - const double ymax = camcoord_bbox.m_max.y; - double dx = 0.5*(xmax - xmin)*scale.x; - double dy = 0.5*(ymax - ymin)*scale.y; - if ( dx <= ON_SQRT_EPSILON && dy <= ON_SQRT_EPSILON) - { - dx = dy = 0.5; - } - - if( dx < dy*aspect ) - dx = dy*aspect; - else - dy = dx/aspect; - - // pad depths a bit so clippling plane are not coplanar with displayed geometry - // zmax is on frustum near and zmin is on frustum far - double zmin = camcoord_bbox.m_min.z; - double zmax = camcoord_bbox.m_max.z; - - // Please discuss any changes to dz calculations with Dale Lear - // before you check in the code. - double dz = (zmax - zmin)*0.00390625; // 0.00390625 = 1/256 - if ( ON::perspective_view == pViewport->Projection() ) - { - // 16 May 2006 Dale Lear - // Do not increase zmax too much or you make zooming to small - // objects in perspective views impossible. To test any - // changes, make a line from (0,0,0) to (0.001,0.001,0.001). - // Make a perspective view with a 50mm lens angle. If you - // can't ZEA on the line, then you've adjusted dz too much. - if ( dz <= 1.0e-6 ) - dz = 1.0e-6; - } - else if ( dz <= 0.125 ) - { - // In parallel projection it is ok to be generous. - dz = 0.125; - } - zmax += dz; - - // It is ok to adjust zmin by more generous amount because it - // does not effect the ability to zoom in on small objects a - // perspective view. - if ( dz <= 0.125 ) - dz = 0.125; - zmin -= dz; - dz = zmax - zmin; - - double frus_near = 0.0; - if( ON::parallel_view == pViewport->Projection() ) - { - // parallel projection - //double cota = 50.0/12.0; // 50 mm lens angle - //frus_near = ((dx > dy) ? dx : dy)*cota; - frus_near = 0.125*dz; - } - else if( ON::perspective_view == pViewport->Projection() ) - { - // perspective projection - double ax, ay; - if ( pViewport->GetCameraAngle(nullptr,&ay,&ax) ) - { - double zx = (ON_IsValid(ax) && ax > 0.0) ? dx/tan(ax) : 0.0; - double zy = (ON_IsValid(ay) && ay > 0.0) ? dy/tan(ay) : 0.0; - frus_near = (zx > zy) ? zx : zy; - } - } - - if ( !ON_IsValid(frus_near) || frus_near <= ON_SQRT_EPSILON ) - { - frus_near = 1.0; - } - - ON_3dPoint camloc = pViewport->CameraLocation(); - if ( camloc.IsValid() ) - { - ON_3dVector dolly = 0.5*(xmax + xmin)*pViewport->CameraX() - + 0.5*(ymax + ymin)*pViewport->CameraY() - + (frus_near + zmax)*pViewport->CameraZ(); - camloc += dolly; - if ( pViewport->SetCameraLocation(camloc) ) - { - double frus_far = frus_near + dz; - rc = pViewport->SetFrustum( -dx, dx, -dy, dy, frus_near, frus_far); - } - } + const ON_BoundingBox camcoord_bbox(ON_3dPoint(camboxmin.val), ON_3dPoint(camboxmax.val)); + rc = ON_DollyExtents(*pViewport, camcoord_bbox, *pViewport); } + return rc; } From 002e24b7c062d72e4569773469208fa1044caefe Mon Sep 17 00:00:00 2001 From: fraguada Date: Mon, 2 Dec 2024 14:52:03 +0100 Subject: [PATCH 4/7] more sync. dotnet compiling finally! --- src/dotnet/RDK/rdk_content.cs | 43 +++- src/dotnet/RDK/rdk_pep.cs | 47 ++++- src/dotnet/UnsafeNativeMethods.cs | 13 +- src/dotnet/hostutils.cs | 168 +++++++++++---- src/dotnet/opennurbs/opennurbs_curve.cs | 134 +++++++++++- src/dotnet/opennurbs/opennurbs_mesh.cs | 4 +- src/dotnet/opennurbs/opennurbs_point.cs | 2 +- src/dotnet/opennurbs/opennurbs_pointcloud.cs | 3 + src/dotnet/opennurbs/opennurbs_rectangle.cs | 45 ++-- src/dotnet/opennurbs/opennurbs_surface.cs | 23 ++ .../opennurbs/opennurbs_texture_mapping.cs | 102 +++++++++ src/dotnet/rhino/rhinosdkapp.cs | 15 ++ src/dotnet/rhino/rhinosdkdisplay.cs | 15 ++ src/dotnet/rhino/rhinosdkdisplayattrsmgr.cs | 11 +- .../rhinosdkdisplaypipelineattributes.cs | 174 +++++++++++++-- src/dotnet/rhino/rhinosdkdoc.cs | 198 ++++++++++++++++-- src/dotnet/rhino/rhinosdkhatchpattern.cs | 140 ++++++++++++- src/dotnet/rhino/rhinosdkmeshobject.cs | 2 +- src/dotnet/rhino/rhinosdkplugin.cs | 34 +++ src/dotnet/rhino/rhinosdkpointobject.cs | 6 +- src/dotnet/rhino/rhinosdkprintinfo.cs | 3 + src/dotnet/rhino/rhinosdkview.cs | 81 +++++++ src/dotnet/rhino/rhinosdkviewport.cs | 15 +- src/librhino3dm_native/on_hatch.cpp | 2 +- src/librhino3dm_native/on_math.cpp | 4 +- src/librhino3dm_native/stdafx.h | 2 +- 26 files changed, 1143 insertions(+), 143 deletions(-) mode change 100644 => 100755 src/dotnet/rhino/rhinosdkdoc.cs mode change 100644 => 100755 src/dotnet/rhino/rhinosdkplugin.cs diff --git a/src/dotnet/RDK/rdk_content.cs b/src/dotnet/RDK/rdk_content.cs index 898036ae6..15c57349a 100644 --- a/src/dotnet/RDK/rdk_content.cs +++ b/src/dotnet/RDK/rdk_content.cs @@ -1982,27 +1982,55 @@ public static System.Drawing.Bitmap GenerateQuickContentPreview(RenderContent c, return bitmap; } - internal static ChangeContexts ChangeContextFromExtraRequirementsSetContext(ExtraRequirementsSetContexts sc) // Static. + /// Specifies optional buttons for ShowContentInstanceBrowser(). + public enum ContentInstanceBrowserButtons + { + /// No optional buttons. + None = 0, + /// Include New button. + NewButton = 1, + /// Include Edit button. + EditButton = 2 + } + + /// + /// 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. + /// Specifies the document to use. + /// Sets the initially selected content and receives the instance id of the chosen content. + /// Specifies the kind(s) of content that should be displayed in the browser. + /// Specifies which optional buttons to display. + /// Returns true if the user chooses a content or false if the dialog is cancelled. + /// + 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) @@ -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) @@ -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"); } diff --git a/src/dotnet/RDK/rdk_pep.cs b/src/dotnet/RDK/rdk_pep.cs index 26332f7ef..dd5601eeb 100644 --- a/src/dotnet/RDK/rdk_pep.cs +++ b/src/dotnet/RDK/rdk_pep.cs @@ -11,7 +11,6 @@ #if RHINO_SDK using DE = Rhino.RDK.Delegates; -using static Rhino.Render.RenderContent; using Rhino.UI.Controls; #endif @@ -160,10 +159,23 @@ public enum PostEffectStyles : int /// 7.0 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, + + /// 8.14 + /// 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 @@ -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) @@ -605,6 +618,7 @@ static internal void SetCppHooks(bool bInitialize) null, null, null, null, null, null, null, null); } } +#endif /// 7.0 public static Type[] RegisterPostEffect(PlugIns.PlugIn plugin) @@ -812,7 +826,7 @@ public override int GetHashCode() // [ANDYLOOK] This does not need to be virtual } /// 7.0 - public void BeginChange(ChangeContexts changeContext) + public void BeginChange(RenderContent.ChangeContexts changeContext) { UnsafeNativeMethods.IRhRdkPostEffect_BeginChange(CppPointer, (int)changeContext); @@ -935,6 +949,8 @@ void Dispose(bool bDisposing) m_cpp = IntPtr.Zero; } } + +#if RHINO_SDK /// /// Add a section to the UI. /// @@ -944,6 +960,7 @@ public void AddSection(ICollapsibleSection section) { UnsafeNativeMethods.IRhRdkPostEffectUI_AddSection(m_cpp, section.CppPointer); } +#endif } internal class PostEffectFactory : PostEffectFactoryBase @@ -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) @@ -1062,6 +1080,7 @@ static internal void SetCppHooks(bool bInitialize) } } } +#endif /// 7.0 [Flags] @@ -1570,6 +1589,7 @@ private static PostEffectJob FromSerialNumber(int serial) /// 7.0 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) @@ -1623,6 +1643,7 @@ static internal void SetCppHooks(bool bInitialize) UnsafeNativeMethods.Rdk_CRdkCmnPostEffectJob_SetCallbacks(null, null, null); } } +#endif } public class PostEffectJobChannels : IDisposable @@ -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); } @@ -2275,7 +2296,7 @@ public abstract class PostEffectExecutionControl : IDisposable { internal int SerialNumber { get; set; } internal IntPtr CppPointer { get; private set; } - +#if RHINO_SDK /// 8.0 public PostEffectExecutionControl() { @@ -2287,7 +2308,7 @@ public PostEffectExecutionControl() PostEffectExecutionControlList._list.Add(new WeakReference(this)); } } - +#endif ~PostEffectExecutionControl() { Dispose(false); @@ -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 } } @@ -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) @@ -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) @@ -2372,6 +2396,7 @@ static internal void SetCppHooks(bool bInitialize) UnsafeNativeMethods.Rdk_CRdkCmnPostEffectExecutionControl_SetCallbacks(null, null); } } - } +#endif + } } diff --git a/src/dotnet/UnsafeNativeMethods.cs b/src/dotnet/UnsafeNativeMethods.cs index 17d27f59c..ad7ca9955 100644 --- a/src/dotnet/UnsafeNativeMethods.cs +++ b/src/dotnet/UnsafeNativeMethods.cs @@ -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); @@ -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)] @@ -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); diff --git a/src/dotnet/hostutils.cs b/src/dotnet/hostutils.cs index ad0da76c4..e4fa35153 100644 --- a/src/dotnet/hostutils.cs +++ b/src/dotnet/hostutils.cs @@ -22,6 +22,15 @@ using System.Text.RegularExpressions; #endif + +/// +/// Attribute used by the iOS AOT (Ahead of Time) compiler to wire up callbacks correctly. +/// +[AttributeUsage(AttributeTargets.Method)] +class MonoPInvokeCallbackAttribute : Attribute { + public MonoPInvokeCallbackAttribute (Type t) {} +} + namespace Rhino.Runtime { /// @@ -1755,6 +1764,7 @@ public static bool GetPrinterFormSize(string printerName, string formName, out d /// /// /// true on success + /// 8.5 public static bool GetPrinterFormMargins(string printerName, string formName, bool portrait, out double leftMillimeters, out double topMillimeters, out double rightMillimeters, out double bottomMillimeters) { @@ -1775,6 +1785,7 @@ public static bool GetPrinterFormMargins(string printerName, string formName, bo /// /// Dot per inch resolution for a given printer on success. 0 if an error occurred /// + /// 8.2 public static double GetPrinterDPI(string printerName, bool horizontal) { return UnsafeNativeMethods.RHC_GetPrinterDPI(printerName, horizontal); @@ -1806,7 +1817,17 @@ public static T GetPlatformService(string assemblyPath = null, string typeFul g_platform_locator[assemblyPath] = new DoNothingLocator(); #if RHINO_SDK var service_type = typeof(IPlatformServiceLocator); - var path = System.IO.Path.Combine(RhinoAssemblyDirectory, assemblyPath); + string path; + if (RunningOnWindows && RunningInNetCore) + { + path = System.IO.Path.Combine(RhinoAssemblyDirectory, "netcore", assemblyPath); + if (!File.Exists(path)) + path = System.IO.Path.Combine(RhinoAssemblyDirectory, assemblyPath); + } + else + { + path = System.IO.Path.Combine(RhinoAssemblyDirectory, assemblyPath); + } var platform_assembly = LoadAssemblyFrom(path); if (typeFullName == null) @@ -1897,6 +1918,7 @@ public static bool ExecuteNamedCallback(string name, NamedParametersEventArgs ar return UnsafeNativeMethods.RHC_RhExecuteNamedCallback(name, args.m_pNamedParams); } + [MonoPInvokeCallback(typeof(NamedCallback))] static int ExecuteNamedCallbackHelper(IntPtr name, IntPtr ptrNamedParams) { try @@ -1913,9 +1935,9 @@ static int ExecuteNamedCallbackHelper(IntPtr name, IntPtr ptrNamedParams) return 1; } } - catch (NotLicensedException nle) + catch (NotLicensedException) { - throw nle; + throw; } catch (Exception ex) { @@ -2048,17 +2070,43 @@ public static void InPlaceConstCast(Rhino.Geometry.GeometryBase geometry, bool m } } + private static bool? _runningOnWindows = null; + private static bool? _runningOnOSX = null; + /// /// Tests if this process is currently executing on the Windows platform. /// /// 5.0 - public static bool RunningOnWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + public static bool RunningOnWindows + { + get + { + if (!_runningOnWindows.HasValue) + { + _runningOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + } + return _runningOnWindows.Value; + } + } /// /// Tests if this process is currently executing on the Mac OSX platform. /// /// 5.0 - public static bool RunningOnOSX => RuntimeInformation.IsOSPlatform(OSPlatform.OSX); + public static bool RunningOnOSX + { + get + { + if (!_runningOnOSX.HasValue) + { + // TODO: S. Baer - Why is RunningOniOS part of this decision? + // I'm assuming this is to get things running on iOS and that we + // can tune this up over time by adding a RunningOnApple propery + _runningOnOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RunningOniOS; + } + return _runningOnOSX.Value; + } + } /// /// Tests if this process is currently executing on the iOS platform. @@ -2109,6 +2157,23 @@ public static bool RunningInWindowsContainer } } + internal static bool TryGetWindowsContainerId(out Guid containerId) + { + try + { + var key = @"HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control"; + var containerIdObj = Microsoft.Win32.Registry.GetValue(key, "ContainerId", null); + if (containerIdObj is string containerIdStr && !string.IsNullOrEmpty(containerIdStr)) + { + return Guid.TryParse(containerIdStr, out containerId); + } + } + catch { } + + containerId = Guid.Empty; + return false; + } + /// /// Returns true if the host operating system is in dark mode and Rhino /// supports dark mode. @@ -2187,6 +2252,10 @@ public static Guid DeviceId bool SerialNumberIsHardwareBased = true; if (m_device_id == Guid.Empty) { + // RH-62726 - use container id if running in a windows container + if (RunningInWindowsContainer && TryGetWindowsContainerId(out m_device_id)) + return m_device_id; + // Base the device ID solely on the HardwareSerialNumber, if one // exists. Otherwise, base it on the first Ethernet MacAddress. // The goal here is to generate a reasonably uniqe and stable @@ -2443,7 +2512,7 @@ static IEnumerable GetSystemReferenceAssembliesInternal() yield return file; } - // Common assemblies + // Common assemblies yield return typeof(System.Windows.Forms.Appearance).Assembly.Location; // System.Windows.Forms.dll yield return typeof(System.Drawing.Bitmap).Assembly.Location; // System.Drawing.dll (net48) / System.Drawing.Common.dll (net6+) @@ -2832,6 +2901,7 @@ public enum LogMessageType : int assert = 4 }; +#if RHINO_SDK /// /// Informs RhinoCommon of an message that has been handled but that the developer wants to screen. /// @@ -2840,6 +2910,7 @@ public enum LogMessageType : int /// The message. /// The messag type /// 6.4 + [MonoPInvokeCallback(typeof(SendLogMessageToCloudCallback))] public static void SendLogMessageToCloudCallbackProc(LogMessageType msg_type, IntPtr pwStringClass, IntPtr pwStringDesc, IntPtr pwStringMessage) { if (IntPtr.Zero == pwStringClass) @@ -2886,6 +2957,7 @@ public static void SendLogMessageToCloudCallbackProc(LogMessageType msg_type, In /// /// 6.4 public static event SendLogMessageToCloudDelegate OnSendLogMessageToCloud; +#endif @@ -3044,7 +3116,8 @@ public static bool RegisterDynamicCommand(PlugIn plugin, Commands.Command cmd) } return rc; } -#endif + + [MonoPInvokeCallback(typeof(GetNowCallback))] static int GetNowHelper(int localeId, IntPtr pStringHolderFormat, IntPtr pResultString) { int rc; @@ -3069,6 +3142,7 @@ static int GetNowHelper(int localeId, IntPtr pStringHolderFormat, IntPtr pResult return rc; } + [MonoPInvokeCallback(typeof(GetFormattedTimeCallback))] static int GetFormattedTimeHelper(int localeId, int sec, int min, int hour, int day, int month, int year, IntPtr pStringHolderFormat, IntPtr pResultString) { int rc; @@ -3090,10 +3164,10 @@ static int GetFormattedTimeHelper(int localeId, int sec, int min, int hour, int return rc; } + [MonoPInvokeCallback(typeof(EvaluateExpressionCallback))] static int EvaluateExpressionHelper(IntPtr statementsAsStringHolder, IntPtr expressionAsStringHolder, uint rhinoDocSerialNumber, IntPtr pResultString) { int rc = 0; -#if RHINO_SDK try { // 11 July 2014 S. Baer (RH-28010) @@ -3105,7 +3179,7 @@ static int EvaluateExpressionHelper(IntPtr statementsAsStringHolder, IntPtr expr PythonScript py = PythonScript.Create(); if (py == null) return 0; - + object eval_result = py.EvaluateExpression(state, expr); System.Threading.Thread.CurrentThread.CurrentCulture = current; if (null != eval_result) @@ -3165,11 +3239,9 @@ static int EvaluateExpressionHelper(IntPtr statementsAsStringHolder, IntPtr expr UnsafeNativeMethods.ON_wString_Set(pResultString, ex.Message); rc = 0; } -#endif return rc; } -#if RHINO_SDK internal static object ParseFieldExpression(string expression, RhinoDoc doc, Rhino.DocObjects.RhinoObject rhinoObject, Rhino.DocObjects.RhinoObject topLevelRhinoObject, Rhino.DocObjects.InstanceObject immediateParentObject, @@ -3188,7 +3260,7 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, //v8 and newer requires proper casing of functions. Please don't add new functions to this list - //Repair the casing of older files to ensure compatibility. + //Repair the casing of older files to ensure compatibility. #region Repair Function Casing var function_name_list = new List() { @@ -3238,7 +3310,7 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, // Skipping ones like "Area" since those always required parentheses #region Add () to function names string[] oldFields = { "Date", "DateModified", "FileName", "ModelUnits", "NumPages", "PageNumber", "PageName", "Notes", "ObjectName" }; - + foreach(var field in oldFields) { if (!formula.StartsWith(field)) @@ -3297,18 +3369,24 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, { if (doc == null) doc = RhinoDoc.ActiveDoc; - TextFields.Setup(doc, rhinoObject, topLevelRhinoObject, immediateParentObject); - // Force the culture to invariant while running the evaluation - var current = System.Threading.Thread.CurrentThread.CurrentCulture; - System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture; - PythonScript py = PythonScript.Create(); - if (py == null) - return 0; - - string statements = "import clr\nfrom math import *\nfrom Rhino.Runtime.TextFields import *\n"; - object eval_result = py.EvaluateExpression(statements, formula); - System.Threading.Thread.CurrentThread.CurrentCulture = current; + object eval_result = null; + { + try + { + TextFields.PushContext(doc, rhinoObject, topLevelRhinoObject, immediateParentObject); + PythonScript py = PythonScript.Create(); + if (py == null) + return "####"; + + string statements = "import clr\nfrom math import *\nfrom Rhino.Runtime.TextFields import *\n"; + eval_result = py.EvaluateExpression(statements, formula); + } + finally + { + TextFields.PopContext(); + } + } if (null != eval_result) { @@ -3333,10 +3411,10 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, } var annotation = rhinoObject as AnnotationObjectBase; - + //Look for block instances with BlockAttributesText and try to fish out an annotation base to get dimension style from - //NOTE this only supports 1 dimension style per block. - if (rhinoObject is InstanceObject block) + //NOTE this only supports 1 dimension style per block. + if (rhinoObject is InstanceObject block) { annotation = block.InstanceDefinition.GetObjects().FirstOrDefault(c=>c.ObjectType == ObjectType.Annotation) as AnnotationObjectBase; } @@ -3344,8 +3422,8 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, if (annotation != null) { //If the object containing the function is an annotation then - //We need to know the space of the object being referenced by the function, not the annotations space. - //strip the referenced object guid out of the expression and figure out what space that object resides in. + //We need to know the space of the object being referenced by the function, not the annotations space. + //strip the referenced object guid out of the expression and figure out what space that object resides in. //Fixes https://mcneel.myjetbrains.com/youtrack/issue/RH-80815 var guid_pattern = @"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; var regex = new Regex(guid_pattern); @@ -3414,7 +3492,6 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, return "####"; } } -#endif /// /// This function is called from the C++ textfield evaluator @@ -3425,10 +3502,11 @@ internal static object ParseFieldExpression(string expression, RhinoDoc doc, /// /// pointer to immediate instance object parent /// + [MonoPInvokeCallback(typeof(EvaluateTextFieldCallback))] static int EvaluateTextFieldHelper(IntPtr ptrFormula, IntPtr pRhinoObject, IntPtr ptrParseResult, IntPtr pTopParent, IntPtr pImmediateParent) { int rc = 0; -#if RHINO_SDK + RhinoDoc doc = null; var rhobj = Rhino.DocObjects.RhinoObject.CreateRhinoObjectHelper(pRhinoObject); if (rhobj != null) @@ -3474,11 +3552,9 @@ static int EvaluateTextFieldHelper(IntPtr ptrFormula, IntPtr pRhinoObject, IntPt StringWrapper.SetStringOnPointer(ptrParseResult, result); rc = success ? 1 : 0; -#endif return rc; } -#if RHINO_SDK /// /// Gets the auto install plug-in folder for machine or current user. /// @@ -3509,7 +3585,7 @@ public static string AutoInstallPlugInFolder(bool currentUser) catch (KeyNotFoundException) { // thrown the first time this is called (by the assembly resolver) on mac - // only happens if UseDebugFolder is *not* set, so let's ignore it + // only happens if UseDebugFolder is *not* set, so let's ignore it } } @@ -3517,6 +3593,7 @@ public static string AutoInstallPlugInFolder(bool currentUser) return path; } + [MonoPInvokeCallback(typeof(Action))] static void BuildRegisteredPlugInList() { try @@ -3713,6 +3790,7 @@ Version GetOSVersion(string name) } } + [MonoPInvokeCallback(typeof(GetAssemblyIdCallback))] static Guid GetAssemblyId(IntPtr path) { try @@ -3755,14 +3833,16 @@ private static Guid GetGuidAttributeValue(string str_path) #endif } - static int LoadPlugInHelper(IntPtr path, IntPtr pluginInfo, IntPtr errorMessage, int displayDebugInfo, bool bIsDirectoryInstall) + [MonoPInvokeCallback(typeof(LoadPluginCallback))] + static int LoadPlugInHelper(IntPtr path, IntPtr pluginInfo, IntPtr errorMessage, int displayDebugInfo, int bIsDirectoryInstall) { string str_path = StringWrapper.GetStringFromPointer (path); - int rc = (int)PlugIn.LoadPlugInHelper(str_path, pluginInfo, errorMessage, displayDebugInfo != 0, bIsDirectoryInstall); + int rc = (int)PlugIn.LoadPlugInHelper(str_path, pluginInfo, errorMessage, displayDebugInfo != 0, bIsDirectoryInstall != 0); return rc; } static Skin g_skin; + [MonoPInvokeCallback(typeof(LoadSkinCallback))] static int LoadSkinHelper(IntPtr path, int displayDebugInfo) { if( g_skin!=null ) @@ -3817,7 +3897,7 @@ static int LoadSkinHelper(IntPtr path, int displayDebugInfo) internal delegate void ShutdownRDKCallback(); static readonly ShutdownRDKCallback m_rdk_shutdown_callback = ShutDownRhinoCommon_RDK; - internal delegate int LoadPluginCallback(IntPtr path, IntPtr pluginInfo, IntPtr errorMessage, int displayDebugInfo, bool bIsDirectoryInstall); + internal delegate int LoadPluginCallback(IntPtr path, IntPtr pluginInfo, IntPtr errorMessage, int displayDebugInfo, int bIsDirectoryInstall); static readonly LoadPluginCallback m_loadplugin_callback = LoadPlugInHelper; internal delegate int LoadSkinCallback(IntPtr path, int displayDebugInfo); static readonly LoadSkinCallback m_loadskin_callback = LoadSkinHelper; @@ -3903,11 +3983,9 @@ public static void InitializeRhinoCommon() /// /// Subsequent calls to this method will be ignored. /// 6.0 + [MonoPInvokeCallback(typeof(InitializeRDKCallback))] public static void InitializeRhinoCommon_RDK() { -#if ON_RUNTIME_APPLE_IOS - // no rhcommonrdk_c on ios yet. -#else if (m_rhinocommonrdkinitialized) return; m_rhinocommonrdkinitialized = true; @@ -3919,12 +3997,14 @@ public static void InitializeRhinoCommon_RDK() Rhino.Render.PostEffects.PostEffect.SetCppHooks(true); Rhino.Render.PostEffects.PostEffectFactoryBase.SetCppHooks(true); Rhino.Render.PostEffects.PostEffectJob.SetCppHooks(true); + Rhino.Render.PostEffects.PostEffectExecutionControl.SetCppHooks(true); Rhino.DocObjects.SnapShots.SnapShotsClient.SetCppHooks(true); Rhino.UI.Controls.FactoryBase.Register(); UnsafeNativeMethods.SetRhCsInternetFunctionalityCallback(Rhino.Render.InternalUtilities.OnDownloadFileProc, Rhino.Render.InternalUtilities.OnUrlResponseProc, Rhino.Render.InternalUtilities.OnBitmapFromSvgProc); +#if !ON_RUNTIME_APPLE_IOS Rhino.ObjectManager.ObjectManagerExtension.SetCppHooks(true); Rhino.ObjectManager.ObjectManagerNode.SetCppHooks(true); #endif @@ -3935,6 +4015,7 @@ public static void InitializeRhinoCommon_RDK() /// /// Subsequent calls to this method will be ignored. /// 6.0 + [MonoPInvokeCallback(typeof(ShutdownRDKCallback))] public static void ShutDownRhinoCommon_RDK() { UnsafeNativeMethods.SetRhCsInternetFunctionalityCallback(null, null, null); @@ -3946,6 +4027,7 @@ public static void ShutDownRhinoCommon_RDK() Rhino.Render.PostEffects.PostEffect.SetCppHooks(false); Rhino.Render.PostEffects.PostEffectFactoryBase.SetCppHooks(false); Rhino.Render.PostEffects.PostEffectJob.SetCppHooks(false); + Rhino.Render.PostEffects.PostEffectExecutionControl.SetCppHooks(false); Rhino.DocObjects.SnapShots.SnapShotsClient.SetCppHooks(false); Rhino.ObjectManager.ObjectManagerExtension.SetCppHooks(false); @@ -3954,6 +4036,10 @@ public static void ShutDownRhinoCommon_RDK() #endif static bool g_ReportExceptions = true; + + [DllImport("RhinoCore")] + private static extern void RHC_ShowCrashReporter(); + /// /// For internal use only!!! /// Unhanded exception handler, writes stack trace to RhinoDotNet.txt file @@ -4163,6 +4249,8 @@ static void DelegateReport(System.Delegate d, string name) internal delegate void ReportCallback(int c); internal static ReportCallback m_ew_report = EventWatcherReport; + + [MonoPInvokeCallback(typeof(ReportCallback))] internal static void EventWatcherReport(int c) { UnsafeNativeMethods.CRhinoEventWatcher_LogState("RhinoCommon delegate based event watcher\n"); diff --git a/src/dotnet/opennurbs/opennurbs_curve.cs b/src/dotnet/opennurbs/opennurbs_curve.cs index 47eaa80de..2cf45ec44 100644 --- a/src/dotnet/opennurbs/opennurbs_curve.cs +++ b/src/dotnet/opennurbs/opennurbs_curve.cs @@ -1225,7 +1225,7 @@ public static Curve[] CreateMatchCurve(Curve curve0, bool reverse0, BlendContinu /// The first, or starting, curve. /// The second, or ending, curve. /// Number of tween curves to create. - /// An array of joint curves. This array can be empty. + /// An array of tween curves. This array can be empty. /// 5.2 /// 6.0 [Obsolete("Use version that takes tolerance as input")] @@ -1245,7 +1245,7 @@ public static Curve[] CreateTweenCurves(Curve curve0, Curve curve1, int numCurve /// The second, or ending, curve. /// Number of tween curves to create. /// - /// An array of joint curves. This array can be empty. + /// An array of tween curves. This array can be empty. /// 6.0 public static Curve[] CreateTweenCurves(Curve curve0, Curve curve1, int numCurves, double tolerance) { @@ -1267,7 +1267,7 @@ public static Curve[] CreateTweenCurves(Curve curve0, Curve curve1, int numCurve /// The first, or starting, curve. /// The second, or ending, curve. /// Number of tween curves to create. - /// An array of joint curves. This array can be empty. + /// An array of tween curves. This array can be empty. /// 5.2 /// 6.0 [Obsolete("Use version that takes tolerance as input")] @@ -1288,7 +1288,7 @@ public static Curve[] CreateTweenCurvesWithMatching(Curve curve0, Curve curve1, /// The second, or ending, curve. /// Number of tween curves to create. /// - /// An array of joint curves. This array can be empty. + /// An array of tween curves. This array can be empty. /// 6.0 public static Curve[] CreateTweenCurvesWithMatching(Curve curve0, Curve curve1, int numCurves, double tolerance) { @@ -1311,7 +1311,7 @@ public static Curve[] CreateTweenCurvesWithMatching(Curve curve0, Curve curve1, /// The second, or ending, curve. /// Number of tween curves to create. /// Number of sample points along input curves. - /// >An array of joint curves. This array can be empty. + /// >An array of tween curves. This array can be empty. /// 5.2 /// 6.0 [Obsolete("Use version that takes tolerance as input")] @@ -1332,8 +1332,8 @@ public static Curve[] CreateTweenCurvesWithSampling(Curve curve0, Curve curve1, /// The second, or ending, curve. /// Number of tween curves to create. /// Number of sample points along input curves. - /// - /// >An array of joint curves. This array can be empty. + /// The tolerance. When in doubt, use the document's model absolute tolerance. + /// >An array of tween curves. This array can be empty. /// 6.0 public static Curve[] CreateTweenCurvesWithSampling(Curve curve0, Curve curve1, int numCurves, int numSamples, double tolerance) { @@ -1796,6 +1796,45 @@ public static Curve[] CreateCurve2View(Curve curveA, Curve curveB, Vector3d vect } } + /// + /// Creates a revision cloud curve from a planar curve. + /// + /// The input planar curve. + /// + /// The number of segments in the output revision cloud curve. + /// If zero, the number of segments in the output revision cloud curve is based on the NURB form of the input curve. + /// + /// + /// The angle in radians, between PI/2.0 and PI radians (90 and 180 degrees). + /// This angle indicates the amount of bulge in the segments. + /// + /// The arc segments in output revision cloud curve will be in the opposite direction to the input curve. + /// A revision cloud curve is successful, false otherwise. + /// 8.4 + public static Curve CreateRevisionCloud(Curve curve, int segmentCount, double angle, bool flip) + { + IntPtr ptr_const_curve = curve.ConstPointer(); + IntPtr ptr = UnsafeNativeMethods.RHC_RhCreateRevisionCloud(ptr_const_curve, segmentCount, angle, flip); + return GeometryBase.CreateGeometryHelper(ptr, null) as Curve; + } + + /// + /// Creates a revision cloud curve from points that make up a planar polyline. + /// + /// The input points. + /// + /// The angle in radians, between PI/2.0 and PI radians (90 and 180 degrees). + /// This angle indicates the amount of bulge in the segments. + /// + /// The arc segments in output revision cloud curve will be in the opposite direction to the input curve. + /// A revision cloud curve is successful, false otherwise. + /// 8.4 + public static Curve CreateRevisionCloud(IEnumerable points, double angle, bool flip) + { + PolylineCurve curve = new PolylineCurve(points); + return CreateRevisionCloud(curve, 0, angle, flip); + } + /// /// Determines whether two curves travel more or less in the same direction. /// @@ -3606,6 +3645,7 @@ public static Curve CreatePeriodicCurve(Curve curve, bool smooth) const int idxPointAtT = 0; const int idxPointAtStart = 1; const int idxPointAtEnd = 2; + const int idxPointAtMid = 3; /// Evaluates point at a curve parameter. /// Evaluation parameter. @@ -3625,6 +3665,7 @@ public Point3d PointAt(double t) UnsafeNativeMethods.ON_Curve_PointAt(ptr, t, ref rc, idxPointAtT); return rc; } + /// /// Evaluates point at the start of the curve. /// @@ -3639,6 +3680,7 @@ public Point3d PointAtStart return rc; } } + /// /// Evaluates point at the end of the curve. /// @@ -3654,7 +3696,41 @@ public Point3d PointAtEnd } } + /// + /// Evaluates point at the middle, or mid, of the curve. + /// + /// 8.14 + public Point3d PointAtMid + { + get + { + Point3d rc = new Point3d(); + IntPtr ptr = ConstPointer(); + UnsafeNativeMethods.ON_Curve_PointAt(ptr, 1, ref rc, idxPointAtMid); + return rc; + } + } + #if RHINO_SDK + + /// + /// Reparameterizes a curve using automatic parameterization. + /// + /// The reparameterized curve if successful, null otherwise. + /// + /// Poorly parameterized objects may not intersect and trim properly when combined with other objects. + /// "Poorly parameterized" means the curve's domain or the surface's u or v spaces are tiny or huge compared to the size of the object. + /// When curves are parameterized with a [0,1] domain, both the accuracy and the precision of geometric calculations like intersections and closest points are reduced, sometimes dramatically. + /// Ideally the domain of a curve is close to it's length. + /// + /// 8.14 + public Curve Reparameterize() + { + IntPtr ptr_const_this = ConstPointer(); + IntPtr rc = UnsafeNativeMethods.ON_Curve_Reparameterize(ptr_const_this); + return GeometryBase.CreateGeometryHelper(rc, null) as Curve; + } + /// /// Gets a point at a certain length along the curve. The length must be /// non-negative and less than or equal to the length of the curve. @@ -4570,6 +4646,11 @@ public double[] DivideByLength(double segmentLength, bool includeEnds, bool reve /// /// The distance between division points. /// An array of equidistant points, or null on error. + /// + /// Unlike the other divide methods, which divides a curve based on arc length, + /// or the distance along the curve between two points, this function divides a curve + /// based on the linear distance between points. + /// /// 5.0 [ConstOperation] public Point3d[] DivideEquidistant(double distance) @@ -4578,9 +4659,46 @@ public Point3d[] DivideEquidistant(double distance) SimpleArrayPoint3d points = new SimpleArrayPoint3d(); IntPtr pConstThis = ConstPointer(); IntPtr pPoints = points.NonConstPointer(); - if (UnsafeNativeMethods.RHC_RhinoDivideCurveEquidistant(pConstThis, distance, pPoints) > 0) + if (UnsafeNativeMethods.RHC_RhinoDivideCurveEquidistant(pConstThis, distance, pPoints, IntPtr.Zero) > 0) + rc = points.ToArray(); + points.Dispose(); + return rc; + } + + /// + /// Calculates 3d points on a curve where the linear distance between the points is equal. + /// + /// The distance between division points. + /// If successful, an array of curve parameters at the point locations. + /// An array of equidistant points, or null on error. + /// + /// Unlike the other divide methods, which divides a curve based on arc length, + /// or the distance along the curve between two points, this function divides a curve + /// based on the linear distance between points. + /// + /// 8.14 + public Point3d[] DivideEquidistant(double distance, out double[] curveParameters) + { + Point3d[] rc = null; + curveParameters = new double[0]; + + IntPtr pConstThis = ConstPointer(); + + SimpleArrayPoint3d points = new SimpleArrayPoint3d(); + IntPtr pPoints = points.NonConstPointer(); + + SimpleArrayDouble parameters = new SimpleArrayDouble(); + IntPtr pParameters = parameters.NonConstPointer(); + + if (UnsafeNativeMethods.RHC_RhinoDivideCurveEquidistant(pConstThis, distance, pPoints, pParameters) > 0) + { rc = points.ToArray(); + curveParameters = parameters.ToArray(); + } + points.Dispose(); + parameters.Dispose(); + return rc; } diff --git a/src/dotnet/opennurbs/opennurbs_mesh.cs b/src/dotnet/opennurbs/opennurbs_mesh.cs index e89cd10f5..5d70147ba 100644 --- a/src/dotnet/opennurbs/opennurbs_mesh.cs +++ b/src/dotnet/opennurbs/opennurbs_mesh.cs @@ -4162,6 +4162,7 @@ public bool EvaluateMeshGeometry(Surface surface) public void SetTextureCoordinates(TextureMapping tm, Transform xf, bool lazy) { UnsafeNativeMethods.ON_Mesh_SetTextureCoordinatesFromMappingAndTransform(NonConstPointer(), tm.ConstPointer(), ref xf, lazy); + GC.KeepAlive(tm); } /// @@ -13820,6 +13821,7 @@ public MeshDisplacementInfo(RenderTexture texture, namespace Rhino.Runtime { +#if RHINO_SDK /// /// Internal class used by ShrinkWrap functions to acces the instance. /// @@ -13841,7 +13843,7 @@ public static IShrinkWrapService Service() } } } - +#endif /// /// Internal interface used by ShrinkWrap functions /// diff --git a/src/dotnet/opennurbs/opennurbs_point.cs b/src/dotnet/opennurbs/opennurbs_point.cs index bebbd2724..1164ca0f5 100644 --- a/src/dotnet/opennurbs/opennurbs_point.cs +++ b/src/dotnet/opennurbs/opennurbs_point.cs @@ -501,7 +501,7 @@ public double NormalizedParameterAt(double intervalParameter) x = (intervalParameter == m_t1) ? 1.0 : (intervalParameter - m_t0) / (m_t1 - m_t0); } else - x = m_t0; + x = 0.0; } else { diff --git a/src/dotnet/opennurbs/opennurbs_pointcloud.cs b/src/dotnet/opennurbs/opennurbs_pointcloud.cs index 9be320304..6f5db9c11 100644 --- a/src/dotnet/opennurbs/opennurbs_pointcloud.cs +++ b/src/dotnet/opennurbs/opennurbs_pointcloud.cs @@ -7,6 +7,9 @@ using Rhino.Runtime; using Rhino.Runtime.InteropWrappers; using System.Threading; +#if RHINO_SDK +using System.Security.Policy; +#endif namespace Rhino.Geometry { diff --git a/src/dotnet/opennurbs/opennurbs_rectangle.cs b/src/dotnet/opennurbs/opennurbs_rectangle.cs index ff2432c3e..26317a69a 100644 --- a/src/dotnet/opennurbs/opennurbs_rectangle.cs +++ b/src/dotnet/opennurbs/opennurbs_rectangle.cs @@ -31,8 +31,7 @@ public struct Rectangle3d : IEpsilonComparable, ICloneable /// 5.0 public static Rectangle3d CreateFromPolyline(IEnumerable polyline) { - double dev, angdev; - return CreateFromPolyline(polyline, out dev, out angdev); + return CreateFromPolyline(polyline, out _, out _); } /// /// Attempts to create a rectangle from a polyline. This method only works well for @@ -56,9 +55,9 @@ public static Rectangle3d CreateFromPolyline(IEnumerable polyline, out angleDeviation = 0.0; // Remove consecutive identical vertices. - Point3d prev = Point3d.Unset; - List points = new List(); - foreach (Point3d point in polyline) + var prev = Point3d.Unset; + var points = new List(); + foreach (var point in polyline) { if (point == prev) continue; if (!point.IsValid) continue; @@ -75,35 +74,31 @@ public static Rectangle3d CreateFromPolyline(IEnumerable polyline, out if (points.Count == 1) return CreateDegenerateRectangle(points[0], points[0]); if (points.Count == 2) return CreateDegenerateRectangle(points[0], points[1]); if (points.Count == 3) points.Add(points[0] + (points[2] - points[1])); - if (points.Count > 5) RecursiveReduceVertices(points); + if (points.Count >= 5) RecursiveReduceVertices(points); - Point3d centre = 0.25 * (points[0] + points[1] + points[2] + points[3]); - Vector3d xaxis = (points[1] - points[0]) + (points[2] - points[3]); - Vector3d yaxis = (points[3] - points[0]) + (points[2] - points[1]); + var centre = 0.25 * (points[0] + points[1] + points[2] + points[3]); + var xaxis = (points[1] - points[0]) + (points[2] - points[3]); + var yaxis = (points[3] - points[0]) + (points[2] - points[1]); bool flip = false; if (xaxis.Length < yaxis.Length) { flip = true; - Vector3d cache = xaxis; - xaxis = yaxis; - yaxis = cache; + (yaxis, xaxis) = (xaxis, yaxis); } - Plane plane = new Plane(centre, xaxis, yaxis); + var plane = new Plane(centre, xaxis, yaxis); if (flip) plane.Flip(); - double x0, x1, x2, x3; - double y0, y1, y2, y3; - plane.ClosestParameter(points[0], out x0, out y0); - plane.ClosestParameter(points[1], out x1, out y1); - plane.ClosestParameter(points[2], out x2, out y2); - plane.ClosestParameter(points[3], out x3, out y3); + plane.ClosestParameter(points[0], out var x0, out var y0); + plane.ClosestParameter(points[1], out var x1, out var y1); + plane.ClosestParameter(points[2], out var x2, out var y2); + plane.ClosestParameter(points[3], out var x3, out var y3); - Interval xdomain = new Interval(0.5 * x0 + 0.5 * x3, 0.5 * x1 + 0.5 * x2); - Interval ydomain = new Interval(0.5 * y0 + 0.5 * y1, 0.5 * y2 + 0.5 * y3); + var xdomain = new Interval(0.5 * x0 + 0.5 * x3, 0.5 * x1 + 0.5 * x2); + var ydomain = new Interval(0.5 * y0 + 0.5 * y1, 0.5 * y2 + 0.5 * y3); - Rectangle3d rec = new Rectangle3d(plane, xdomain, ydomain); + var rec = new Rectangle3d(plane, xdomain, ydomain); ComputeDeviation(rec, points, out deviation, out angleDeviation); return rec; } @@ -173,7 +168,7 @@ private static void RecursiveReduceVertices(List p) { while (p.Count > 4) { - double minD = double.MaxValue; + var minD = double.MaxValue; int minI = -1; int n = p.Count; @@ -182,8 +177,8 @@ private static void RecursiveReduceVertices(List p) int k0 = (i - 1 + n) % n; int k1 = (i + 1) % n; - Line segment = new Line(p[k0], p[k1]); - double localD = segment.DistanceTo(p[i], true); + var segment = new Line(p[k0], p[k1]); + var localD = segment.DistanceTo(p[i], true); if (localD < minD) { minD = localD; diff --git a/src/dotnet/opennurbs/opennurbs_surface.cs b/src/dotnet/opennurbs/opennurbs_surface.cs index c40738a7b..b47eecdd7 100644 --- a/src/dotnet/opennurbs/opennurbs_surface.cs +++ b/src/dotnet/opennurbs/opennurbs_surface.cs @@ -1279,6 +1279,29 @@ public bool IsSubDFriendly #region statics + /// + /// Create tween surfaces that gradually transition between two bounding surfaces using point sampling. + /// + /// The first, or starting, surface. + /// The second, or ending, curve. + /// Number of tween surfaces to create. + /// Number of sample points along input surfaces. + /// The tolerance. When in doubt, use the document's model absolute tolerance. + /// >An array of tween surfaces if successful, an empty array on error. + /// 8.14 + public static Surface[] CreateTweenSurfacesWithSampling(Surface surface0, Surface surface1, int numSurfaces, int numSamples, double tolerance) + { + IntPtr ptr_const_srf0 = surface0.ConstPointer(); + IntPtr ptr_const_srf1 = surface1.ConstPointer(); + using (SimpleArraySurfacePointer output = new SimpleArraySurfacePointer()) + { + IntPtr ptr_output = output.NonConstPointer(); + bool rc = UnsafeNativeMethods.RHC_RhinoTweenSurfacesSamplePoints(ptr_const_srf0, ptr_const_srf1, numSurfaces, numSamples, tolerance, ptr_output); + Runtime.CommonObject.GcProtect(surface0, surface1); + return rc ? output.ToNonConstArray() : Array.Empty(); + } + } + /// /// Constructs a rolling ball fillet between two surfaces. /// diff --git a/src/dotnet/opennurbs/opennurbs_texture_mapping.cs b/src/dotnet/opennurbs/opennurbs_texture_mapping.cs index f49460707..9cfe42aa9 100644 --- a/src/dotnet/opennurbs/opennurbs_texture_mapping.cs +++ b/src/dotnet/opennurbs/opennurbs_texture_mapping.cs @@ -44,6 +44,59 @@ public enum TextureMappingType : int FalseColors = UnsafeNativeMethods.TextureMappingType.FalseColors } + /// + /// Texture space + /// + /// When a mapping primitive is a box or a capped cylinder, + /// there are two options for the mapping. Either the sides + /// all map to (0,1)x(0,1) (so the either texture map appears + /// on each side, or the sides map to distinct regions of the + /// texture space. + /// + /// + public enum TextureSpace : int + { + /// + /// sides and caps map to same texture space + /// + Single = 0, + /// + /// regions of texture space. + /// (0, 1/4, 2/4, 3/4, 1) for uncapped boxes. + /// (0, 1/6, 2/6, 3/6, 4/6, 5/6, 1) for capped boxes. + /// (0, 4/6, 5/6, 1) for capped cylinders. + /// + Divided = 1 + }; + + /// + /// When a mapping primitive, like a plane, sphere, box, + /// or cylinder, is used, there are two projection options. + ///If m_type = srfp_mapping, then m_projection is ignored. + /// + public enum Projection : int + { + /// + /// None + /// + None = 0, + /// + /// ClosestPoint: world xyz maps to the point on the + /// mapping primitive that is closest to xyz. + /// In this case, ON_TextureMapping::Evaluate + /// ignores the vector argument. + /// + ClosestPoint = 1, + /// + /// Ray: world xyz + world vector defines a world line. + /// The world line is intersected with the mapping + /// primitive and the intersection point that is + /// closest to the world xyz point is used to + /// calculate the mapping parameters. + /// + Ray = 2 + }; + /// /// Represents a texture mapping. /// @@ -116,6 +169,55 @@ public TextureMappingType MappingType } } + /// + /// // The m_bCapped applies to planar, cylinder and box mappings. + /// If m_bCapped is false, the cylinder or box is "infinite", if m_bCapped is true, they are finite. + /// In planar mappings, m_bCapped=false means "the Z texture coordinate will always be 0.0" + /// this is now the default behaviour in Rhino 5.0 - it's what users expect apparently. + /// + public bool Capped + { + get + { + return UnsafeNativeMethods.ON_TextureMapping_GetCapped(ConstPointer()); + } + set + { + UnsafeNativeMethods.ON_TextureMapping_SetCapped(NonConstPointer(), value); + } + } + + /// + /// See TextureSpace + /// + public TextureSpace TextureSpace + { + get + { + return (TextureSpace)UnsafeNativeMethods.ON_TextureMapping_GetTextureSpace(ConstPointer()); + } + set + { + UnsafeNativeMethods.ON_TextureMapping_SetTextureSpace(NonConstPointer(), (int)value); + } + } + + /// + /// See Projection + /// + public Projection Projection + { + get + { + return (Projection)UnsafeNativeMethods.ON_TextureMapping_GetProjection(ConstPointer()); + } + set + { + UnsafeNativeMethods.ON_TextureMapping_SetProjection(NonConstPointer(), (int)value); + } + } + + /// /// The unique Id for this texture mapping object. diff --git a/src/dotnet/rhino/rhinosdkapp.cs b/src/dotnet/rhino/rhinosdkapp.cs index 98543d278..641aa8a86 100644 --- a/src/dotnet/rhino/rhinosdkapp.cs +++ b/src/dotnet/rhino/rhinosdkapp.cs @@ -514,6 +514,21 @@ public static Guid CurrentRhinoId get { return UnsafeNativeMethods.CRhinoApp_GetGUID(UnsafeNativeMethods.RhinoAppGuid.CurrentRhinoId); } } + /// + /// Returns true if Rhino's parent window is the desktop, false otherwise. + /// + /// + /// The parent of a top-level window is the desktop window. + /// Some applications like to re-parent Rhino's main window to a window they provide. + /// Use this property to determine if Rhino is in such a condition. + /// Note, this property is only valid on Windows. + /// + /// 8.14 + public static bool IsParentDesktop + { + get { return UnsafeNativeMethods.CRhinoApp_IsParentDesktop(); } + } + /// Is Rhino currently being executed through automation /// 5.0 public static bool IsRunningAutomated diff --git a/src/dotnet/rhino/rhinosdkdisplay.cs b/src/dotnet/rhino/rhinosdkdisplay.cs index 7d6a4ab08..a2b185471 100644 --- a/src/dotnet/rhino/rhinosdkdisplay.cs +++ b/src/dotnet/rhino/rhinosdkdisplay.cs @@ -127,6 +127,21 @@ private DisplayBitmap(IntPtr pBmp) m_ptr_display_bmp = pBmp; } + /// + /// Update the image used for this DisplayBitmap + /// + /// + public void Update(System.Drawing.Bitmap bitmap) + { + IntPtr hbmp = bitmap.GetHbitmap(); + if (m_ptr_display_bmp == IntPtr.Zero) + { + m_ptr_display_bmp = UnsafeNativeMethods.CRhCmnDisplayBitmap_New(null, hbmp); + return; + } + UnsafeNativeMethods.CRhCmnDisplayBitmap_Update(m_ptr_display_bmp, hbmp); + } + /// /// Load a DisplayBitmap from and image file on disk or from URL. If path starts /// with http:// or https:// then an attempt is made to load the bitmap from an diff --git a/src/dotnet/rhino/rhinosdkdisplayattrsmgr.cs b/src/dotnet/rhino/rhinosdkdisplayattrsmgr.cs index c6d412abe..70f87f055 100644 --- a/src/dotnet/rhino/rhinosdkdisplayattrsmgr.cs +++ b/src/dotnet/rhino/rhinosdkdisplayattrsmgr.cs @@ -459,8 +459,17 @@ public static Guid RaytracedId } } + public static Guid MonochromeId + { + get + { + return + UnsafeNativeMethods.ON_MaterialRef_DisplayModeSpecialType( + UnsafeNativeMethods.DisplayModeSpecialType.Monochrome); + } + } #endregion - + } } #endif diff --git a/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs b/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs index d18f44dd8..c7efa5e70 100644 --- a/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs +++ b/src/dotnet/rhino/rhinosdkdisplaypipelineattributes.cs @@ -647,7 +647,7 @@ public void SetCurveThicknessUsage(CurveThicknessUse usage) [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] public CurveThicknessUse GetCurveThicknessUsage() { - return (CurveThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage); + return (CurveThicknessUse)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.CurveThicknessUsage); } //bool m_bUseDefaultCurve; -- doesn't appear to be used in display pipelane @@ -850,7 +850,7 @@ public void SetSurfaceNakedEdgeThicknessUsage(SurfaceNakedEdgeThicknessUse use) /// 8.6 public SurfaceNakedEdgeThicknessUse GetSurfaceNakedEdgeThicknessUsage() { - if (GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceNakedEdgeUseNormalEdgeThickness)) + if (GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.SurfaceNakedEdgeUseNormalEdgeThickness)) return SurfaceNakedEdgeThicknessUse.UseSurfaceEdgeSettings; SurfaceEdgeThicknessFlags currentUsage = (SurfaceEdgeThicknessFlags)GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.SurfaceThicknessUsage); if (0 != (SurfaceEdgeThicknessFlags.NakedEdgeFixedWidth & currentUsage)) @@ -938,7 +938,7 @@ public bool SurfaceIsoThicknessUsed get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoThicknessUsed); } set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.IsoThicknessUsed, value); } } - + /// /// Turn pattern application on or off /// @@ -988,7 +988,7 @@ public enum SurfaceEdgeColorUse : int } /// 8.6 public SurfaceEdgeColorUse SurfaceEdgeColorUsage - { + { get { return (SurfaceEdgeColorUse)GetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorUsage); } set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.EdgeColorUsage, (int)value); } } @@ -1167,7 +1167,7 @@ public float SurfaceIsoThicknessVScale { get { return GetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoVThicknessScale); } set { SetFloat(UnsafeNativeMethods.DisplayPipelineAttributesFloat.SurfaceIsoVThicknessScale, value); } - } + } /// 8.7 public float SurfaceIsoThicknessWScale { @@ -1361,7 +1361,7 @@ public LightingSchema LightingScheme //bool m_bUseHiddenLights; //bool m_bUseLightColor; //bool m_bUseDefaultLightingScheme; - + //bool m_bUseDefaultEnvironment; //int m_nLuminosity; /// 6.3 @@ -1744,7 +1744,7 @@ public bool ShowRealtimeRenderProgressBar get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowRealtimeRenderProgressBar); } set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.ShowRealtimeRenderProgressBar, value); } } -#endregion + #endregion /// /// Get or set the stereo render context. @@ -1835,7 +1835,7 @@ public double BackMaterialTransparency /// 8.8 public Color BackMaterialDiffuseColor { - get + get { return GetColor(UnsafeNativeMethods.DisplayAttrsColor.BackDiffuse); } @@ -2690,11 +2690,11 @@ public bool ShadowsOn public int ShadowIntensity { get { return GetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowIntensity); } - set + set { if (value < 0) value = 0; else if (value > 100) value = 100; - SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowIntensity, value); + SetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowIntensity, value); } } /// @@ -2750,7 +2750,7 @@ private enum ShadowMapType : uint /// public int ShadowSoftEdgeQuality { - get + get { if (GetInt(UnsafeNativeMethods.DisplayAttributesInt.ShadowMapType) == (int)ShadowMapType.Normal) return 0; @@ -2782,11 +2782,11 @@ public int ShadowSoftEdgeQuality public double ShadowEdgeBlur { get { return GetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBlur); } - set + set { if (value < 0.0f) value = 0.0f; if (value > 16.0f) value = 16.0f; - SetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBlur, value); + SetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBlur, value); } } /// @@ -2795,7 +2795,7 @@ public double ShadowEdgeBlur public double ShadowBiasX { get { return GetDouble(UnsafeNativeMethods.DisplayAttributesDouble.ShadowBiasX); } - set + set { if (value < 0.0) value = 0.0; if (value > 50.0) value = 50.0; @@ -2838,12 +2838,12 @@ public float ShadowClippingRadius public bool ShadowsIgnoreUserDefinedClippingPlanes { get { return (0 != (0x10 & GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage))); } - set + set { int current = GetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage); if (value) current |= 0x10; if (!value) current &= ~0x10; - SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage, current); + SetByte(UnsafeNativeMethods.DisplayPipelineAttributesByte.ShadowClippingUsage, current); } } @@ -2947,6 +2947,148 @@ public Color GridPlaneColor set { SetColor(UnsafeNativeMethods.DisplayAttrsColor.GridPlaneColor, value); } } + /// + /// + /// + public enum GroundPlaneUsages + { + ByDocument = 0, + Custom = 1, + } + + /// + /// Turn on or off custom Ground plane settungs + /// + public GroundPlaneUsages GroundPlaneUsage + { + get { return (GroundPlaneUsages)GetInt(UnsafeNativeMethods.DisplayAttributesInt.GroundPlaneUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.GroundPlaneUsage, (int) value); } + } + + /// + /// + /// + public enum LinearWorkflowUsages + { + ByDocument=0, + Custom=1, + } + + /// + /// Turn on or off custom linear workflow settings + /// + public LinearWorkflowUsages LinearWorkflowUsage + { + get { return (LinearWorkflowUsages)GetInt(UnsafeNativeMethods.DisplayAttributesInt.LinearWorkflowUsage); } + set { SetInt(UnsafeNativeMethods.DisplayAttributesInt.LinearWorkflowUsage, (int)value); } + } + + /// + /// Linear workflow input colors + /// + public bool PreProcessColors + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessColors); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessColors, value); } + } + + /// + /// Linear workflow input textures + /// + public bool PreProcessTextures + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessTextures); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessTextures, value); } + } + + /// + /// Linear workflow input gamma + /// + public bool PreProcessGamma + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessGamma); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PreProcessGamma, value); } + } + + /// + /// Linear workflow Adjust output image + /// + public bool PostProcessFrameBuffer + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PostProcessFrameBuffer); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PostProcessFrameBuffer, value); } + } + + /// + /// Linear workflow Output image gamma + /// + public bool PostProcessGamma + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PostProcessGamma); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.PostProcessGamma, value); } + } + + /// + /// Shades the current viewport with no smoothing so the individual render mesh faces are visible. + /// + public bool FrontFlatShaded + { + get + { + IntPtr ptr = NonConstPointer(); + return UnsafeNativeMethods.CDisplayPipelineAttributes_DisplayAttributeMaterial_GetBool(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttributesMaterialBool.FlatShaded); + } + set + { + IntPtr ptr = NonConstPointer(); + UnsafeNativeMethods.CDisplayPipelineAttributes_DisplayAttributeMaterial_SetBool(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttributesMaterialBool.FlatShaded, value); + } + } + + /// + /// + /// + public bool FrontOverrideObjectColor + { + get + { + IntPtr ptr = NonConstPointer(); + return UnsafeNativeMethods.CDisplayPipelineAttributes_DisplayAttributeMaterial_GetBool(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttributesMaterialBool.MatOverrideObjectColor); + } + set + { + IntPtr ptr = NonConstPointer(); + UnsafeNativeMethods.CDisplayPipelineAttributes_DisplayAttributeMaterial_SetBool(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttributesMaterialBool.MatOverrideObjectColor, value); + } + } + + /// + /// Shades the current viewport with no smoothing so the individual render mesh faces are visible. + /// + public Color FrontDiffuse + { + get + { + IntPtr ptr = NonConstPointer(); + return System.Drawing.Color.FromArgb(UnsafeNativeMethods.CDisplayAttributeMaterial_GetColor(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttrsMaterialColor.Diffuse)); + } + set + { + IntPtr ptr = NonConstPointer(); + UnsafeNativeMethods.CDisplayAttributeMaterial_SetColor(ptr, UnsafeNativeMethods.DisplayAttributesMaterialIdx.FrontMaterial, UnsafeNativeMethods.DisplayAttrsMaterialColor.Diffuse, value.ToArgb()); + } + } + + /// + /// Adds the ability to display procedural textures in viewports. When it is turned off, procedural textures in viewports look different from the rendering. + /// + public bool BakeTextures + { + get { return GetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.BakeTextures); } + set { SetBool(UnsafeNativeMethods.DisplayPipelineAttributesBool.BakeTextures, value); } + } + + } } diff --git a/src/dotnet/rhino/rhinosdkdoc.cs b/src/dotnet/rhino/rhinosdkdoc.cs old mode 100644 new mode 100755 index b322e7c04..09544ad9b --- a/src/dotnet/rhino/rhinosdkdoc.cs +++ b/src/dotnet/rhino/rhinosdkdoc.cs @@ -355,8 +355,8 @@ public static RhinoDoc Open(string filePath, out bool wasAlreadyOpen) { // only open the document if not yet opened, otherwise // active doc serial# will be out of sync, see RH-82580 - if (!UnsafeNativeMethods.CRhinoFileMenu_Open(filePath)) - return null; + if (!UnsafeNativeMethods.CRhinoFileMenu_Open(filePath)) + return null; doc = FromFilePath(filePath); } return doc; @@ -2102,7 +2102,7 @@ public RenderMeshes[] RenderMeshes(MeshType mt, ViewportInfo vp, ref RenderMeshP foreach (var id in a) { - var primitives = new RenderMeshes(this, id, Guid.Empty, 0); + var primitives = new RenderMeshes(this, id, Guid.Empty, 0, (uint)flags); UnsafeNativeMethods.Rdk_CustomRenderMeshes_IManager_CustomMeshes((int)mt, primitives.NonConstPointer(), vp.ConstPointer(), RuntimeSerialNumber, id, ref f, plugin.NonConstPointer(), attrs.ConstPointer(), IntPtr.Zero); @@ -3636,14 +3636,15 @@ public static event EventHandler Befo if (g_before_transform_objects == null) { g_on_before_transform_objects_callback = OnBeforeTransformObjects; - UnsafeNativeMethods.CRhinoEventWatcher_SetTransformObjectsCallback(g_on_before_transform_objects_callback); + UnsafeNativeMethods.CRhinoEventWatcher_SetBeforeTransformObjectsCallback(g_on_before_transform_objects_callback); } // ReSharper disable once DelegateSubtraction - okay for single value g_before_transform_objects -= value; @@ -3681,12 +3682,65 @@ public static event EventHandler Befo g_before_transform_objects -= value; if (g_before_transform_objects == null) { - UnsafeNativeMethods.CRhinoEventWatcher_SetTransformObjectsCallback(null); + UnsafeNativeMethods.CRhinoEventWatcher_SetBeforeTransformObjectsCallback(null); g_on_before_transform_objects_callback = null; } } } } + #endregion + + #region After transform event + internal delegate void RhinoAfterTransformObjectsCallback(IntPtr pRhinoAfterTransformObject); + private static RhinoAfterTransformObjectsCallback g_on_after_transform_objects_callback; + [MonoPInvokeCallback(typeof(RhinoAfterTransformObjectsCallback))] + private static void OnAfterTransformObjects(IntPtr pRhinoAfterTransformObject) + { + if (g_after_transform_objects != null) + { + var args = new DocObjects.RhinoAfterTransformObjectsEventArgs(pRhinoAfterTransformObject); + g_after_transform_objects.SafeInvoke(null, args); + args.CleanUp(); + } + } + static EventHandler g_after_transform_objects; + /// + /// Called after objects are being transformed + /// + /// + /// + /// 8.15 + public static event EventHandler AfterTransformObjects + { + add + { + lock (g_event_lock) + { + if (g_after_transform_objects == null) + { + g_on_after_transform_objects_callback = OnAfterTransformObjects; + UnsafeNativeMethods.CRhinoEventWatcher_SetAfterTransformObjectsCallback(g_on_after_transform_objects_callback); + } + // ReSharper disable once DelegateSubtraction - okay for single value + g_after_transform_objects -= value; + g_after_transform_objects += value; + } + } + remove + { + lock (g_event_lock) + { + // ReSharper disable once DelegateSubtraction - okay for single value + g_after_transform_objects -= value; + if (g_after_transform_objects == null) + { + UnsafeNativeMethods.CRhinoEventWatcher_SetAfterTransformObjectsCallback(null); + g_on_after_transform_objects_callback = null; + } + } + } + } + #endregion internal delegate void RhinoTableCallback(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings); @@ -3787,6 +3841,58 @@ public static event EventHandler LinetypeTableEvent } #endregion + #region HatchPattern table event + private static RhinoTableCallback g_on_hatchpattern_table_event_callback; + private static GCHandle g_hatchpattern_callback_gchandle; + [MonoPInvokeCallback(typeof(RhinoTableCallback))] + private static void OnHatchPatternTableEvent(uint docSerialNumber, int eventType, int index, IntPtr pConstOldSettings) + { + m_hatchpattern_table_event?.SafeInvoke(null, new HatchPatternTableEventArgs(docSerialNumber, eventType, index, pConstOldSettings)); + } + internal static EventHandler m_hatchpattern_table_event; + + /// + /// Called when any modification happens to a document's hatch pattern table. + /// + /// 8.15 + public static event EventHandler HatchPatternTableEvent + { + add + { + lock (g_event_lock) + { + if (m_hatchpattern_table_event == null) + { + g_on_hatchpattern_table_event_callback = OnHatchPatternTableEvent; + g_hatchpattern_callback_gchandle = GCHandle.Alloc(g_on_hatchpattern_table_event_callback); + + UnsafeNativeMethods.CRhinoEventWatcher_SetHatchPatternTableEventCallback(g_on_hatchpattern_table_event_callback, Runtime.HostUtils.m_ew_report); + } + // ReSharper disable once DelegateSubtraction - okay for single value + m_hatchpattern_table_event -= value; + m_hatchpattern_table_event += value; + } + } + remove + { + lock (g_event_lock) + { + // ReSharper disable once DelegateSubtraction - okay for single value + m_hatchpattern_table_event -= value; + if (m_hatchpattern_table_event == null) + { + UnsafeNativeMethods.CRhinoEventWatcher_SetHatchPatternTableEventCallback(null, Runtime.HostUtils.m_ew_report); + g_on_hatchpattern_table_event_callback = null; + if (g_hatchpattern_callback_gchandle.IsAllocated) + { + g_hatchpattern_callback_gchandle.Free(); + } + } + } + } + } + #endregion + #region Dimension style table event private static RhinoTableCallback g_on_dim_style_table_event_callback; [MonoPInvokeCallback(typeof(RhinoTableCallback))] @@ -4795,9 +4901,9 @@ public RhinoObject[] RhinoObjects { m_objects = rhobjs; return m_objects; - } + } objects.AddRange(rhobjs); - } + } m_objects = objects.ToArray(); } return m_objects; @@ -4941,6 +5047,7 @@ public ObjectAttributes OldAttributes /// /// EventArgs passed to RhinoDoc.BeforeTransform. /// + /// 5.10 public class RhinoTransformObjectsEventArgs : EventArgs { IntPtr m_ptr_transform_object; @@ -4948,9 +5055,9 @@ public class RhinoTransformObjectsEventArgs : EventArgs GripObject[] m_grips; RhinoObject[] m_grip_owners; - internal RhinoTransformObjectsEventArgs(IntPtr pRhinoOnTransformObject) + internal RhinoTransformObjectsEventArgs(IntPtr pRhinoBeforeTransformObject) { - m_ptr_transform_object = pRhinoOnTransformObject; + m_ptr_transform_object = pRhinoBeforeTransformObject; } internal void CleanUp() @@ -4958,6 +5065,19 @@ internal void CleanUp() m_ptr_transform_object = IntPtr.Zero; } + /// + /// The transformation event id. + /// + /// 8.15 + [CLSCompliant(false)] + public uint TransformEventId + { + get + { + return UnsafeNativeMethods.CRhinoBeforeTransformObject_TransformEventId(m_ptr_transform_object); + } + } + /// /// The transformation to be applied. /// @@ -4967,7 +5087,7 @@ public Transform Transform get { Transform xf = Transform.Identity; - UnsafeNativeMethods.CRhinoOnTransformObject_Transform(m_ptr_transform_object, ref xf); + UnsafeNativeMethods.CRhinoBeforeTransformObject_Transform(m_ptr_transform_object, ref xf); return xf; } } @@ -4976,7 +5096,7 @@ public Transform Transform /// True if the objects will be copied. /// /// 5.10 - public bool ObjectsWillBeCopied => UnsafeNativeMethods.CRhinoOnTransformObject_Copy(m_ptr_transform_object); + public bool ObjectsWillBeCopied => UnsafeNativeMethods.CRhinoBeforeTransformObject_Copy(m_ptr_transform_object); private const int idxObjectCount = 0; private const int idxGripCount = 1; @@ -4986,19 +5106,19 @@ public Transform Transform /// The number of Rhino objects that will be transformed. /// /// 5.10 - public int ObjectCount => UnsafeNativeMethods.CRhinoOnTransformObject_ObjectCount(m_ptr_transform_object, idxObjectCount); + public int ObjectCount => UnsafeNativeMethods.CRhinoBeforeTransformObject_ObjectCount(m_ptr_transform_object, idxObjectCount); /// /// The number of Rhino object grips that will be transformed. /// /// 7.0 - public int GripCount => UnsafeNativeMethods.CRhinoOnTransformObject_ObjectCount(m_ptr_transform_object, idxGripCount); + public int GripCount => UnsafeNativeMethods.CRhinoBeforeTransformObject_ObjectCount(m_ptr_transform_object, idxGripCount); /// /// The number of Rhino object grip owners that will be changed when the grips are transformed. /// /// 7.0 - public int GripOwnerCount => UnsafeNativeMethods.CRhinoOnTransformObject_ObjectCount(m_ptr_transform_object, idxGripOwnerCount); + public int GripOwnerCount => UnsafeNativeMethods.CRhinoBeforeTransformObject_ObjectCount(m_ptr_transform_object, idxGripOwnerCount); /// /// An array of Rhino objects to be transformed. @@ -5017,7 +5137,7 @@ public RhinoObject[] Objects m_objects = new RhinoObject[count]; for (int i = 0; i < count; i++) { - IntPtr ptr_rhino_object = UnsafeNativeMethods.CRhinoOnTransformObject_Object(m_ptr_transform_object, i); + IntPtr ptr_rhino_object = UnsafeNativeMethods.CRhinoBeforeTransformObject_Object(m_ptr_transform_object, i); m_objects[i] = RhinoObject.CreateRhinoObjectHelper(ptr_rhino_object); } } @@ -5042,7 +5162,7 @@ public GripObject[] Grips m_grips = new GripObject[count]; for (int i = 0; i < count; i++) { - IntPtr ptr_grip_object = UnsafeNativeMethods.CRhinoOnTransformObject_Grip(m_ptr_transform_object, i); + IntPtr ptr_grip_object = UnsafeNativeMethods.CRhinoBeforeTransformObject_Grip(m_ptr_transform_object, i); var sn = UnsafeNativeMethods.CRhinoObject_RuntimeSN(ptr_grip_object); if (IntPtr.Zero != ptr_grip_object && sn > 0) { @@ -5072,7 +5192,7 @@ public RhinoObject[] GripOwners m_grip_owners = new RhinoObject[count]; for (int i = 0; i < count; i++) { - IntPtr ptr_rhino_object = UnsafeNativeMethods.CRhinoOnTransformObject_GripOwner(m_ptr_transform_object, i); + IntPtr ptr_rhino_object = UnsafeNativeMethods.CRhinoBeforeTransformObject_GripOwner(m_ptr_transform_object, i); m_grip_owners[i] = RhinoObject.CreateRhinoObjectHelper(ptr_rhino_object); } } @@ -5080,6 +5200,38 @@ public RhinoObject[] GripOwners } } } + + /// + /// EventArgs passed to RhinoDoc.AfterTransform. + /// + /// 8.15 + public class RhinoAfterTransformObjectsEventArgs : EventArgs + { + IntPtr m_ptr_transform_object; + + internal RhinoAfterTransformObjectsEventArgs(IntPtr pRhinoAfterTransformObject) + { + m_ptr_transform_object = pRhinoAfterTransformObject; + } + + internal void CleanUp() + { + m_ptr_transform_object = IntPtr.Zero; + } + + /// + /// The transformation event id. + /// + /// 8.15 + [CLSCompliant(false)] + public uint TransformEventId + { + get + { + return UnsafeNativeMethods.CRhinoAfterTransformObject_TransformEventId(m_ptr_transform_object); + } + } + } } } @@ -7501,7 +7653,7 @@ public Guid AddExtrusion(Extrusion extrusion, ObjectAttributes attributes, Histo IntPtr pHistory = (history == null) ? IntPtr.Zero : history.Handle; return UnsafeNativeMethods.CRhinoDoc_AddExtrusion(m_doc.RuntimeSerialNumber, pConstExtrusion, pConstAttributes, pHistory, reference); } - + public Guid AddClippingPlaneSurface(Geometry.ClippingPlaneSurface clippingPlane, ObjectAttributes attributes, HistoryRecord history, bool reference) { IntPtr pConstClippingPlane = clippingPlane.ConstPointer(); diff --git a/src/dotnet/rhino/rhinosdkhatchpattern.cs b/src/dotnet/rhino/rhinosdkhatchpattern.cs index 3e8025b48..5d7b85dda 100644 --- a/src/dotnet/rhino/rhinosdkhatchpattern.cs +++ b/src/dotnet/rhino/rhinosdkhatchpattern.cs @@ -308,9 +308,18 @@ public sealed class HatchPattern : ModelComponent public HatchPattern() : base() { // Creates a new non-document control ON_HatchPattern - IntPtr pHP = UnsafeNativeMethods.ON_HatchPattern_New(); + IntPtr pHP = UnsafeNativeMethods.ON_HatchPattern_New(IntPtr.Zero); ConstructNonConstObject(pHP); } + + /// 8.15 + public HatchPattern(HatchPattern other) : base() + { + IntPtr pOther = other.ConstPointer(); + IntPtr pHatchPattern = UnsafeNativeMethods.ON_HatchPattern_New(pOther); + ConstructNonConstObject(pHatchPattern); + } + #if RHINO_SDK internal HatchPattern(int index, RhinoDoc doc) : base() { @@ -435,6 +444,22 @@ internal override IntPtr _InternalDuplicate(out bool applymempressure) /// 5.0 public override bool IsReference => base.IsReference; + /// + /// Returns true if the hatch pattern is in use by a Rhino object, + /// a layer, an instance definition, or a section style. + /// + /// 8.15 + public bool InUse + { + get + { + if (null == m_doc) + return false; + int index = Index; + return UnsafeNativeMethods.CRhinoHatchPatternTable_InUse(m_doc.RuntimeSerialNumber, index); + } + } + /// /// Creates preview line segments of the hatch pattern. /// @@ -758,6 +783,119 @@ public static HatchPattern Squares #if RHINO_SDK namespace Rhino.DocObjects.Tables { + /// + /// HatchPattern event types + /// 8.15 + /// + public enum HatchPatternTableEventType + { + /// + /// A hatchpattern was added. + /// + Added = 0, + /// + /// A hatchpattern was deleted. + /// + Deleted = 1, + /// + /// A hatchpattern was undeleted. + /// + Undeleted = 2, + /// + /// A hatchpattern was modified. + /// + Modified = 3, + /// + /// The hatchpattern table was sorted. + /// + Sorted = 4, + /// + /// The current hatchpattern has changed. + /// + Current = 5 + } + + /// + /// LinetypeTable event arguments + /// 8.15 + /// + public class HatchPatternTableEventArgs : EventArgs + { + readonly private uint m_doc_sn; + readonly private HatchPatternTableEventType m_event_type; + readonly private int m_hatchpattern_index; + readonly private IntPtr m_ptr_old_hatchpattern; + + internal HatchPatternTableEventArgs(uint docSerialNumber, int eventType, int index, IntPtr pConstOldHatchPattern) + { + m_doc_sn = docSerialNumber; + m_event_type = (HatchPatternTableEventType)eventType; + m_hatchpattern_index = index; + m_ptr_old_hatchpattern = pConstOldHatchPattern; + } + + /// + /// The document in which the event occurred. + /// + /// 8.15 + public RhinoDoc Document + { + get { return m_doc ?? (m_doc = RhinoDoc.FromRuntimeSerialNumber(m_doc_sn)); } + } + private RhinoDoc m_doc; + + /// + /// The event type. + /// + /// 8.15 + public HatchPatternTableEventType EventType + { + get { return m_event_type; } + } + + /// + /// Index of the hatchpattern. + /// + /// 8.15 + public int HatchPatternIndex + { + get { return m_hatchpattern_index; } + } + + /// + /// The new state. + /// + /// 8.15 + public HatchPattern NewState + { + get { return m_new_hatchpattern ?? (m_new_hatchpattern = new HatchPattern(HatchPatternIndex, Document)); } + } + private HatchPattern m_new_hatchpattern; + + /// + /// The old state. + /// + /// 8.15 + public HatchPattern OldState + { + get + { + if (m_old_hatchpattern == null && m_ptr_old_hatchpattern != IntPtr.Zero) + { + // 14 July 2022 - S. Baer + // m_ptr_old_linetype is const and is deleted when this EventWatcher event + // completes. Make a copy when OldState is accessed so we don't end up + // with a double delete in the LineType finalizer. + IntPtr pHatchPattern = UnsafeNativeMethods.ON_HatchPattern_New(m_ptr_old_hatchpattern); + m_old_hatchpattern = new HatchPattern(pHatchPattern); + } + return m_old_hatchpattern; + } + } + private HatchPattern m_old_hatchpattern; + } + + /// /// All of the hatch pattern definitions contained in a rhino document. /// diff --git a/src/dotnet/rhino/rhinosdkmeshobject.cs b/src/dotnet/rhino/rhinosdkmeshobject.cs index aaa3af24f..a82964460 100644 --- a/src/dotnet/rhino/rhinosdkmeshobject.cs +++ b/src/dotnet/rhino/rhinosdkmeshobject.cs @@ -69,7 +69,7 @@ protected Mesh SetMesh(Mesh mesh) if (raw_mesh_ptr != IntPtr.Zero) { new_mesh = new Mesh(raw_mesh_ptr, null); - new_mesh.ConvertToConstObjectWithSharedPointerParent(p_shared_ptr_to_old_mesh); + new_mesh.ConvertToConstObjectWithSharedPointerParent(p_shared_ptr_to_old_mesh); } else { diff --git a/src/dotnet/rhino/rhinosdkplugin.cs b/src/dotnet/rhino/rhinosdkplugin.cs old mode 100644 new mode 100755 index adcb002b3..848c72065 --- a/src/dotnet/rhino/rhinosdkplugin.cs +++ b/src/dotnet/rhino/rhinosdkplugin.cs @@ -2030,6 +2030,14 @@ public static string[] GetInstalledPlugInFolders() } } } + if (HostUtils.RunningInNetFramework) + { + // ensure we don't ever pass back System\netcore folder + // assemblies there are not compatible in this mode. + var netcorePath = Path.Combine(HostUtils.RhinoAssemblyDirectory, "netcore"); + if (dirs.Contains(netcorePath)) + dirs.Remove(netcorePath); + } return dirs.ToArray(); } @@ -2119,6 +2127,32 @@ public static Guid IdFromPath(string pluginPath) return rc; } + /// + /// Attempt to get a plugiin id from just the filename of a plug-in + /// + /// plug-in filename + /// id on success; Guid.Empty if no plug-in could be found + public static Guid IdFromFileName(string filename) + { + Guid rc = UnsafeNativeMethods.CRhinoPlugInManager_IdFromFileName(filename); + if (rc.Equals(Guid.Empty)) + { + // Look in our local collection of plug-ins. We may be in "OnLoad" + // and the plug-in hasn't officially been registered with Rhino. + for (int i = 0; i < m_plugins.Count; i++) + { + string pluginFilename = m_plugins[i].Assembly.Location; + pluginFilename = Path.GetFileName(pluginFilename); + if (pluginFilename.Equals(filename, StringComparison.InvariantCultureIgnoreCase)) + { + rc = m_plugins[i].Id; + break; + } + } + } + return rc; + } + /// /// Gets the id of an installed plug-in giving the plug-in's name. /// diff --git a/src/dotnet/rhino/rhinosdkpointobject.cs b/src/dotnet/rhino/rhinosdkpointobject.cs index 2d03705c0..ad9a429da 100644 --- a/src/dotnet/rhino/rhinosdkpointobject.cs +++ b/src/dotnet/rhino/rhinosdkpointobject.cs @@ -110,7 +110,7 @@ public Point3d OriginalLocation /// 5.0 public bool Moved { - get + get { IntPtr ptr = ConstPointer(); return UnsafeNativeMethods.CRhinoGripObject_Moved(ptr); @@ -162,7 +162,7 @@ public void Move(Point3d newLocation) public void UndoMove() { IntPtr ptr = NonConstPointer_I_KnowWhatImDoing(); - UnsafeNativeMethods.CRhinoGripObject_UndoMode(ptr); + UnsafeNativeMethods.CRhinoGripObject_UndoMode(ptr); } /// @@ -177,7 +177,7 @@ public virtual double Weight IntPtr ptr = ConstPointer(); return UnsafeNativeMethods.CRhinoGripObject_GetSetWeight(ptr, false, 0); } - set + set { IntPtr ptr = NonConstPointer_I_KnowWhatImDoing(); UnsafeNativeMethods.CRhinoGripObject_GetSetWeight(ptr, true, value); diff --git a/src/dotnet/rhino/rhinosdkprintinfo.cs b/src/dotnet/rhino/rhinosdkprintinfo.cs index cd65a2fcc..f27629ebe 100644 --- a/src/dotnet/rhino/rhinosdkprintinfo.cs +++ b/src/dotnet/rhino/rhinosdkprintinfo.cs @@ -1295,6 +1295,9 @@ public double ArrowheadSizeMillimeters /// /// Font point size use for printing text dots. The default value is 10.0. + /// This has morphed into a scale setting as individual text dots have + /// their own sizes. A value of 20 will print dots at double of their size + /// setting while a value of 10 will print with no scaling applied. /// /// 7.27 public double TextDotPointSize diff --git a/src/dotnet/rhino/rhinosdkview.cs b/src/dotnet/rhino/rhinosdkview.cs index bbcf22406..e6837d59e 100644 --- a/src/dotnet/rhino/rhinosdkview.cs +++ b/src/dotnet/rhino/rhinosdkview.cs @@ -839,6 +839,46 @@ void DrawOverlay(object sender, DrawEventArgs e) private static ViewCallback g_on_view_modified; private static EventHandler g_view_modified; + ////////////////////////// + // 22-Nov-2024 Dale Fugier, https://mcneel.myjetbrains.com/youtrack/issue/RH-84877 + internal delegate void ViewEnableDrawingCallback(uint documentSerialNumber, bool drawingEnabled); + private static ViewEnableDrawingCallback g_view_enable_drawing_callback; + private static EventHandler g_view_enable_drawing_handler; + private static void OnViewEnableDrawingChanged(uint documentSerialNumber, bool drawingEnabled) + { + g_view_enable_drawing_handler?.SafeInvoke(null, new ViewEnableDrawingEventArgs(documentSerialNumber, drawingEnabled)); + } + + /// + /// Called when the state of changes. + /// + public static event EventHandler EnableDrawingChanged + { + add + { + if (Runtime.HostUtils.ContainsDelegate(g_view_enable_drawing_handler, value)) + return; + if (g_view_enable_drawing_handler == null) + { + g_view_enable_drawing_callback = OnViewEnableDrawingChanged; + UnsafeNativeMethods.CRhinoEventWatcher_SetViewEnableDrawingCallback(g_view_enable_drawing_callback); + } + g_view_enable_drawing_handler -= value; + g_view_enable_drawing_handler += value; + } + remove + { + g_view_enable_drawing_handler -= value; + if (g_view_enable_drawing_handler == null) + { + UnsafeNativeMethods.CRhinoEventWatcher_SetDetailEventCallback(null); + g_view_enable_drawing_handler = null; + } + } + } + // 22-Nov-2024 Dale Fugier, https://mcneel.myjetbrains.com/youtrack/issue/RH-84877 + ////////////////////////// + //typedef int (CALLBACK* RHMOUSEEVENTCALLBACK_PROC)(unsigned int viewSerialNumber, unsigned int flags, int x, int y, int cancel); internal delegate int MouseCallback(uint viewSerialNumber, uint flags, int x, int y, int cancel); private static MouseCallback g_on_begin_mouse_move; @@ -1217,6 +1257,7 @@ internal static event EventHandler MouseHover g_on_mouse_hover = null; } } + internal static event EventHandler MouseLeave { add @@ -1242,6 +1283,10 @@ internal static event EventHandler MouseLeave #endregion } + /// + /// View event arguments. + /// + /// 5.0 public class ViewEventArgs : EventArgs { readonly IntPtr m_ptr_view; @@ -1263,6 +1308,10 @@ public RhinoView View } } + /// + /// PageView space change event arguments. + /// + /// 5.0 public class PageViewSpaceChangeEventArgs : EventArgs { readonly IntPtr m_ptr_pageview; @@ -1350,6 +1399,38 @@ public RhinoPageView PageView } } } + + /// + /// View enable drawing event argument. + /// + /// 8.15 + public class ViewEnableDrawingEventArgs : EventArgs + { + internal ViewEnableDrawingEventArgs(uint documentSerialNumber, bool drawingEnabled) + { + DocumentSerialNumber = documentSerialNumber; + DrawingEnabled = drawingEnabled; + } + + /// + /// The serial number of the Rhino document. + /// + /// 8.15 + [CLSCompliant(false)] + public uint DocumentSerialNumber { get; private set; } + + /// + /// True if drawing is enabled, false otherwise. + /// + /// 8.15 + public bool DrawingEnabled { get; private set; } + + /// + /// Gets the Rhino document. + /// + /// 8.15 + public RhinoDoc Document => RhinoDoc.FromRuntimeSerialNumber(DocumentSerialNumber); + } } #endif diff --git a/src/dotnet/rhino/rhinosdkviewport.cs b/src/dotnet/rhino/rhinosdkviewport.cs index 079081d8d..0bdaf8e2a 100644 --- a/src/dotnet/rhino/rhinosdkviewport.cs +++ b/src/dotnet/rhino/rhinosdkviewport.cs @@ -19,7 +19,8 @@ public enum DefinedViewportProjection Front = 5, Back = 6, Perspective = 7, - TwoPointPerspective = 8 + TwoPointPerspective = 8, + ParallelReflected = 9, } /// @@ -1291,7 +1292,17 @@ public bool ChangeToTwoPointPerspectiveProjection(double targetDistance, Rhino.G lensLength); } - const int idxCameraLocation = 0; + /// + /// When a viewport is set to Parallel Reflected projection, the geometry on the ceiling is shown as if it is mirrored to the floor below. + /// + /// + public bool ChangeToParallelReflectedProjection() + { + IntPtr ptr_this = NonConstPointer(); + return UnsafeNativeMethods.CRhinoViewport_VP_ChangeToParallelReflectedProjection(ptr_this); + } + + const int idxCameraLocation = 0; const int idxCameraDirection = 1; const int idxCameraUp = 2; const int idxCameraX = 3; diff --git a/src/librhino3dm_native/on_hatch.cpp b/src/librhino3dm_native/on_hatch.cpp index 01667628c..42e4fec61 100644 --- a/src/librhino3dm_native/on_hatch.cpp +++ b/src/librhino3dm_native/on_hatch.cpp @@ -1,6 +1,6 @@ #include "stdafx.h" -RH_C_FUNCTION ON_HatchPattern* ON_HatchPattern_New() +RH_C_FUNCTION ON_HatchPattern* ON_HatchPattern_New(const ON_HatchPattern* pConstHatchPattern) { if (pConstHatchPattern) return new ON_HatchPattern(*pConstHatchPattern); diff --git a/src/librhino3dm_native/on_math.cpp b/src/librhino3dm_native/on_math.cpp index 4d433cd90..5c3f95a02 100644 --- a/src/librhino3dm_native/on_math.cpp +++ b/src/librhino3dm_native/on_math.cpp @@ -60,7 +60,7 @@ RH_C_FUNCTION bool ONC_EvNormalPartials( typedef double (*Callback1Delegate)(ON__UINT_PTR context, int limit_direction, double t); typedef double (*Callback2Delegate)(ON__UINT_PTR context, int limit_direction, double s, double t); - +#if !defined(RHINO3DM_BUILD) RH_C_FUNCTION double ON_Integrate_1D(void* func, void* context, ON_INTERVAL_STRUCT limits, double relative_tolerance, double absolute_tolerance, double* error_bound) { if (context && func) @@ -73,6 +73,7 @@ RH_C_FUNCTION double ON_Integrate_1D(void* func, void* context, ON_INTERVAL_STRU return 0.0; } + RH_C_FUNCTION double ON_Integrate_1D_Curve(void* func, void* context, const ON_Curve* curve, double relative_tolerance, double absolute_tolerance, double* error_bound) { if (curve && func && context) @@ -104,3 +105,4 @@ RH_C_FUNCTION double ON_Integrate_2D_Surface(void* func, void* context, const ON // DALE LEAR thinks you should return ON_DBL_QNAN if the input is bogus return 0.0; } +#endif diff --git a/src/librhino3dm_native/stdafx.h b/src/librhino3dm_native/stdafx.h index 1fe1adfdf..100679ecb 100644 --- a/src/librhino3dm_native/stdafx.h +++ b/src/librhino3dm_native/stdafx.h @@ -49,7 +49,7 @@ // NOTE: THIS NEEDS TO BE CHANGED WHEN WE RELEASE A PUBLIC BUILD #define RHINO_CORE_COMPONENT 1 -#include "../lib//opennurbs/opennurbs.h" +#include "../lib/opennurbs/opennurbs.h" #endif // Rhino System Plug-in linking pragmas From 401ea56e3674c38820c0f8affd3e95233077dc71 Mon Sep 17 00:00:00 2001 From: fraguada Date: Mon, 2 Dec 2024 15:18:27 +0100 Subject: [PATCH 5/7] a bit more sync --- src/dotnet/opennurbs/opennurbs_viewport.cs | 10 ++++++++++ src/dotnet/rhino/rhinosdkobject.cs | 4 ++-- src/librhino3dm_native/on_math.cpp | 3 +-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/dotnet/opennurbs/opennurbs_viewport.cs b/src/dotnet/opennurbs/opennurbs_viewport.cs index 871344c36..69bd9d90e 100644 --- a/src/dotnet/opennurbs/opennurbs_viewport.cs +++ b/src/dotnet/opennurbs/opennurbs_viewport.cs @@ -233,6 +233,16 @@ public bool ChangeToParallelProjection(bool symmetricFrustum) return UnsafeNativeMethods.ON_Viewport_ChangeToParallelProjection(ptr_this, symmetricFrustum); } + /// + /// When a viewport is set to Parallel Reflected projection, the geometry on the ceiling is shown as if it is mirrored to the floor below. + /// + /// true if successful + public bool ChangeToParallelReflectedProjection() + { + IntPtr ptr_this = NonConstPointer(); + return UnsafeNativeMethods.ON_Viewport_ChangeToParallelReflectedProjection(ptr_this); + } + /// /// Use this function to change projections of valid viewports /// from parallel to perspective. It will make common additional diff --git a/src/dotnet/rhino/rhinosdkobject.cs b/src/dotnet/rhino/rhinosdkobject.cs index 2943a0b23..69c250611 100644 --- a/src/dotnet/rhino/rhinosdkobject.cs +++ b/src/dotnet/rhino/rhinosdkobject.cs @@ -2270,7 +2270,7 @@ public bool HasCustomRenderMeshes(MeshType mt, ViewportInfo vp, ref RenderMeshPr uint f = (uint)flags; - f |= 8 /*RenderMeshProvider.Flags.IsDocumentObject*/; + f |= 8 /*RenderMeshProvider.Flags.IsDocumentObject*/; IntPtr ptrViewport = (vp != null) ? vp.ConstPointer() : IntPtr.Zero; @@ -2307,7 +2307,7 @@ public RenderMeshes RenderMeshes(MeshType mt, ViewportInfo vp, List Date: Mon, 2 Dec 2024 15:24:02 +0100 Subject: [PATCH 6/7] do not need this reference to immutable --- src/dotnet/resolver.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/dotnet/resolver.cs b/src/dotnet/resolver.cs index 6bd73f3c7..fd97044a6 100644 --- a/src/dotnet/resolver.cs +++ b/src/dotnet/resolver.cs @@ -6,7 +6,6 @@ using System.Linq; using System.Collections; using System.Runtime.InteropServices; -using System.Collections.Immutable; namespace Rhino.Runtime { From 0aee5534705d87ade2cabce78fbe5162a5c2a766 Mon Sep 17 00:00:00 2001 From: fraguada Date: Mon, 2 Dec 2024 15:26:34 +0100 Subject: [PATCH 7/7] around #if --- src/dotnet/resolver.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/dotnet/resolver.cs b/src/dotnet/resolver.cs index fd97044a6..6a7700b86 100644 --- a/src/dotnet/resolver.cs +++ b/src/dotnet/resolver.cs @@ -6,6 +6,9 @@ using System.Linq; using System.Collections; using System.Runtime.InteropServices; +#if RHINO_SDK +using System.Collections.Immutable; +#endif namespace Rhino.Runtime {