/// <summary> /// Constructs a subclass of this object on the stack in your Rhino plug-in's Render() or RenderWindow() implementation. /// </summary> /// <param name="doc">A Rhino document.</param> /// <param name="mode">A command running mode, such as scripted or interactive.</param> /// <param name="plugin">A plug-in.</param> /// <param name="sizeRendering">The width and height of the rendering.</param> /// <param name="caption">The caption to display in the frame window.</param> /// <param name="channels">The color channel or channels.</param> /// <param name="reuseRenderWindow">true if the rendering window should be reused; otherwise, a new one will be instanciated.</param> /// <param name="clearLastRendering">true if the last rendering should be removed.</param> protected RenderPipeline(RhinoDoc doc, Rhino.Commands.RunMode mode, Rhino.PlugIns.PlugIn plugin, System.Drawing.Size sizeRendering, string caption, Rhino.Render.RenderWindow.StandardChannels channels, bool reuseRenderWindow, bool clearLastRendering ) { Debug.Assert(Rhino.PlugIns.RenderPlugIn.RenderCommandContextPointer != IntPtr.Zero); m_serial_number = m_current_serial_number++; m_all_render_pipelines.Add(m_serial_number, this); m_size = sizeRendering; m_channels = channels; m_pSdkRender = UnsafeNativeMethods.Rdk_SdkRender_New(m_serial_number, Rhino.PlugIns.RenderPlugIn.RenderCommandContextPointer, plugin.NonConstPointer(), caption, reuseRenderWindow, clearLastRendering); m_plugin = plugin; UnsafeNativeMethods.Rdk_RenderWindow_Initialize(m_pSdkRender, (int)channels, m_size.Width, m_size.Height); }
/* public static Rhino.Geometry.Curve TryCopyFromOnCurve(object source) { if (source != null) { try { Type base_type = Type.GetType("RMA.OpenNURBS.OnCurve"); System.Type t = source.GetType(); if (t.IsAssignableFrom(base_type)) { System.Reflection.PropertyInfo pi = t.GetProperty("InternalPointer"); IntPtr ptr = (IntPtr)pi.GetValue(source, null); Rhino.Geometry.Curve crv = Rhino.Geometry.Curve.CreateCurveHelper(ptr, null); crv.NonConstPointer(); return crv; } } catch (Exception) { } } return null; } /// <summary> /// Do not hold on to the returned class outside the scope of your current function. /// </summary> /// <param name="source">-</param> /// <returns>-</returns> public static Rhino.Display.DisplayPipeline ConvertFromMRhinoDisplayPipeline(object source) { if (source != null) { try { Type base_type = Type.GetType("RMA.Rhino.MRhinoDisplayPipeline"); System.Type t = source.GetType(); if (t.IsAssignableFrom(base_type)) { System.Reflection.PropertyInfo pi = t.GetProperty("InternalPointer"); IntPtr ptr = (IntPtr)pi.GetValue(source, null); return new Rhino.Display.DisplayPipeline(ptr); } } catch (Exception) { } } return null; } */ #if RHINO_SDK /// <summary> /// Gets a C++ plug-in pointer for a given RhinoCommon plug-in. /// <para>This is a Rhino SDK function.</para> /// </summary> /// <param name="plugin">A plug-in.</param> /// <returns>A pointer.</returns> public static IntPtr PlugInPointer(Rhino.PlugIns.PlugIn plugin) { return null == plugin ? IntPtr.Zero : plugin.NonConstPointer(); }
/// <summary> /// Sets dynamic grip locations back to starting grip locations. This makes things /// like the Copy command work when grips are "copied". /// </summary> /// <param name="list">A list of object to transform. This is a special list type.</param> protected void ResetGrips(Rhino.Collections.TransformObjectList list) { IntPtr pList = list.NonConstPointer(); UnsafeNativeMethods.CRhinoTransformCommand_ResetGrips(Id, pList); }
protected void TransformObjects(Rhino.Collections.TransformObjectList list, Rhino.Geometry.Transform xform, bool copy, bool autoHistory) { IntPtr pList = list.NonConstPointer(); UnsafeNativeMethods.CRhinoTransformCommand_TransformObjects(Id, pList, ref xform, copy, autoHistory); }
/// <summary> /// Selects objects within the command. /// </summary> /// <param name="prompt">The selection prompt.</param> /// <param name="list">A list of objects to transform. This is a special list type.</param> /// <returns>The operation result.</returns> protected Result SelectObjects(string prompt, Rhino.Collections.TransformObjectList list) { IntPtr pList = list.NonConstPointer(); int rc = UnsafeNativeMethods.CRhinoTransformCommand_SelectObjects(Id, prompt, pList); return (Result)rc; }
public bool PickGumball(Rhino.Input.Custom.PickContext pickContext, Rhino.Input.Custom.GetPoint getPoint) { IntPtr pThis = NonConstPointer(); IntPtr pConstPickContext = pickContext.ConstPointer(); IntPtr pGetPoint = IntPtr.Zero; if( getPoint!=null) getPoint.NonConstPointer(); return UnsafeNativeMethods.CRhinoGumballDisplayConduit_PickGumball(pThis, pConstPickContext, pGetPoint); }
protected void AddGrip(Rhino.DocObjects.Custom.CustomGripObject grip) { m_grip_list.Add(grip); IntPtr pGrip = grip.NonConstPointer(); IntPtr pThis = NonConstPointer(); UnsafeNativeMethods.CRhinoObjectGrips_AddGrip(pThis, pGrip); }
/// <summary> /// Expert user tool that copies user data that has a positive /// CopyCount from the source object to a destination object. /// Generally speaking you don't need to use Copy(). /// Simply rely on things like the copy constructors to do the right thing. /// </summary> /// <param name="source">A source object for the data.</param> /// <param name="destination">A destination object for the data.</param> public static void Copy(Rhino.Runtime.CommonObject source, Rhino.Runtime.CommonObject destination) { IntPtr pConstSource = source.ConstPointer(); IntPtr pDestination = destination.NonConstPointer(); UnsafeNativeMethods.ON_Object_CopyUserData(pConstSource, pDestination); }
public static RdkPlugIn GetRdkPlugIn(Rhino.PlugIns.PlugIn plugin) { for (int i = 0; i < m_all_rdk_plugins.Count; i++) { if (m_all_rdk_plugins[i].m_rhino_plugin_id == plugin.Id) return m_all_rdk_plugins[i]; } IntPtr pRhinoPlugIn = plugin.NonConstPointer(); return GetRdkPlugInHelper(pRhinoPlugIn, plugin.Id, plugin.m_runtime_serial_number); }
/// <summary>Turns on/off the object's editing grips.</summary> /// <param name="customGrips">The custom object grips.</param> /// <returns> /// true if the call succeeded. If you attempt to add custom grips to an /// object that does not support custom grips, then false is returned. /// </returns> public bool EnableCustomGrips(Rhino.DocObjects.Custom.CustomObjectGrips customGrips) { IntPtr pConstThis = ConstPointer(); IntPtr pGrips = customGrips==null?IntPtr.Zero:customGrips.NonConstPointer(); bool rc = UnsafeNativeMethods.CRhinoObject_EnableCustomGrips(pConstThis, pGrips); if (rc && customGrips != null) { customGrips.OnAttachedToRhinoObject(this); } return rc; }