internal IntPtr NonConstPointer()
        {
            if (m_ptr_attributes != IntPtr.Zero)
            {
                return(m_ptr_attributes);
            }

            // Check pipeline_parent first since this is typically time critical
            // code when this is used.
            DisplayPipeline pipeline_parent = m_parent as DisplayPipeline;

            if (pipeline_parent != null)
            {
                // We can cheat and use a const pointer for the non-const version. This is
                // because when a pipeline is associated with attributes, it typically
                // happens when conduits are involved. When conduits are being called, the
                // attributes are exposed as a non const pointer.
                return(pipeline_parent.DisplayAttributeConstPointer());
            }

            DisplayModeDescription parent = m_parent as DisplayModeDescription;

            if (parent != null)
            {
                return(parent.DisplayAttributeNonConstPointer());
            }
            return(IntPtr.Zero);
        }
Example #2
0
        internal IntPtr NonConstPointer()
        {
            if (m_pAttrs != IntPtr.Zero)
            {
                return(m_pAttrs);
            }

            // Check pipeline_parent first since this is typically time critical
            // code when this is used.
            DisplayPipeline pipeline_parent = m_parent as DisplayPipeline;

            if (pipeline_parent != null)
            {
                // Can't change the attributes in a pipeline, so create a copy
                // under the hood
                IntPtr pConstAttributes = ConstPointer();
                if (pConstAttributes != IntPtr.Zero)
                {
                    m_pAttrs = UnsafeNativeMethods.CDisplayPipelineAttributes_New2(pConstAttributes);
                    m_parent = null;
                    return(m_pAttrs);
                }
            }

            DisplayModeDescription parent = m_parent as DisplayModeDescription;

            if (parent != null)
            {
                return(parent.DisplayAttributeNonConstPointer());
            }
            return(IntPtr.Zero);
        }
Example #3
0
 /// <summary>
 /// Exports a DisplayModeDescription to a Windows-style .ini file.
 /// </summary>
 /// <param name="displayMode">The DisplayModeDescription to export.</param>
 /// <param name="filename">The name of the file to create.</param>
 /// <returns></returns>
 /// <since>6.0</since>
 public static bool ExportToFile(DisplayModeDescription displayMode, string filename)
 {
     if (null == displayMode || string.IsNullOrEmpty(filename))
     {
         return(false);
     }
     return(UnsafeNativeMethods.RHC_RhExportDisplayAttrsMgrListDesc(displayMode.Id, filename));
 }
Example #4
0
    public static Rhino.Commands.Result ObjectDisplayMode(Rhino.RhinoDoc doc)
    {
        const ObjectType filter = ObjectType.Mesh | ObjectType.Brep;
        ObjRef           objref;
        Result           rc = Rhino.Input.RhinoGet.GetOneObject("Select mesh or surface", true, filter, out objref);

        if (rc != Rhino.Commands.Result.Success)
        {
            return(rc);
        }
        Guid viewportId = doc.Views.ActiveView.ActiveViewportID;

        ObjectAttributes attr = objref.Object().Attributes;

        if (attr.HasDisplayModeOverride(viewportId))
        {
            RhinoApp.WriteLine("Removing display mode override from object");
            attr.RemoveDisplayModeOverride(viewportId);
        }
        else
        {
            Rhino.Display.DisplayModeDescription[] modes = Rhino.Display.DisplayModeDescription.GetDisplayModes();
            Rhino.Display.DisplayModeDescription   mode  = null;
            if (modes.Length == 1)
            {
                mode = modes[0];
            }
            else
            {
                Rhino.Input.Custom.GetOption go = new Rhino.Input.Custom.GetOption();
                go.SetCommandPrompt("Select display mode");
                string[] str_modes = new string[modes.Length];
                for (int i = 0; i < modes.Length; i++)
                {
                    str_modes[i] = modes[i].EnglishName.Replace(" ", "").Replace("-", "");
                }
                go.AddOptionList("DisplayMode", str_modes, 0);
                if (go.Get() == Rhino.Input.GetResult.Option)
                {
                    mode = modes[go.Option().CurrentListOptionIndex];
                }
            }
            if (mode == null)
            {
                return(Rhino.Commands.Result.Cancel);
            }
            attr.SetDisplayModeOverride(mode, viewportId);
        }
        doc.Objects.ModifyAttributes(objref, attr, false);
        doc.Views.Redraw();
        return(Rhino.Commands.Result.Success);
    }
Example #5
0
        /// <summary>
        /// Gets all display mode descriptions that Rhino currently knows about.
        /// </summary>
        /// <returns>
        /// Copies of all of the display mode descriptions. If you want to modify
        /// these descriptions, you must call UpdateDisplayMode or AddDisplayMode.
        /// </returns>
        /// <example>
        /// <code source='examples\vbnet\ex_advanceddisplay.vb' lang='vbnet'/>
        /// <code source='examples\cs\ex_advanceddisplay.cs' lang='cs'/>
        /// <code source='examples\py\ex_advanceddisplay.py' lang='py'/>
        /// </example>
        public static DisplayModeDescription[] GetDisplayModes()
        {
            IntPtr pDisplayAttrsMgrList = UnsafeNativeMethods.DisplayAttrsMgrList_New();
            int    count = UnsafeNativeMethods.CRhinoDisplayAttrsMgr_GetDisplayAttrsList(pDisplayAttrsMgrList);

            if (count < 1)
            {
                return(new DisplayModeDescription[0]);
            }
            DisplayModeDescription[] rc = new DisplayModeDescription[count];
            for (int i = 0; i < count; i++)
            {
                IntPtr pDisplayMode = UnsafeNativeMethods.DisplayAttrsMgrListDesc_NewFromList(pDisplayAttrsMgrList, i);
                if (pDisplayMode != IntPtr.Zero)
                {
                    rc[i] = new DisplayModeDescription(pDisplayMode);
                }
            }
            UnsafeNativeMethods.DisplayAttrsMgrList_Delete(pDisplayAttrsMgrList);
            return(rc);
        }
        internal IntPtr ConstPointer()
        {
            if (m_ptr_attributes != IntPtr.Zero)
            {
                return(m_ptr_attributes);
            }

            // Check pipeline_parent first since this is typically time critical
            // code when this is used.
            DisplayPipeline pipeline_parent = m_parent as DisplayPipeline;

            if (pipeline_parent != null)
            {
                return(pipeline_parent.DisplayAttributeConstPointer());
            }

            DisplayModeDescription parent = m_parent as DisplayModeDescription;

            if (parent != null)
            {
                return(parent.DisplayAttributeConstPointer());
            }
            return(IntPtr.Zero);
        }
Example #7
0
 /// <summary>
 /// Capture View contents to a bitmap using a display mode description to define
 /// how drawing is performed.
 /// </summary>
 /// <param name="mode">The display mode.</param>
 /// <returns>A new bitmap.</returns>
 /// <since>5.0</since>
 public System.Drawing.Bitmap CaptureToBitmap(DisplayModeDescription mode)
 {
     return(CaptureToBitmap(ClientRectangle.Size, mode));
 }
Example #8
0
        /// <summary>
        /// Capture View contents to a bitmap using a display mode description to define
        /// how drawing is performed.
        /// </summary>
        /// <param name="size">The width and height of the returned bitmap.</param>
        /// <param name="mode">The display mode.</param>
        /// <returns>A new bitmap.</returns>
        /// <since>5.0</since>
        public System.Drawing.Bitmap CaptureToBitmap(System.Drawing.Size size, DisplayModeDescription mode)
        {
            var attr = new DisplayPipelineAttributes(mode);

            return(CaptureToBitmap(size, attr));
        }
 internal DisplayPipelineAttributes(DisplayModeDescription parent)
 {
     m_parent = parent;
 }
Example #10
0
        /// <example>
        /// <code source='examples\vbnet\ex_advanceddisplay.vb' lang='vbnet'/>
        /// <code source='examples\cs\ex_advanceddisplay.cs' lang='cs'/>
        /// <code source='examples\py\ex_advanceddisplay.py' lang='py'/>
        /// </example>
        public static bool UpdateDisplayMode(DisplayModeDescription displayMode)
        {
            IntPtr pConstDisplayMode = displayMode.ConstPointer();

            return(UnsafeNativeMethods.CRhinoDisplayAttrsMgr_Update(pConstDisplayMode));
        }
Example #11
0
        public static Guid AddDisplayMode(DisplayModeDescription displayMode)
        {
            IntPtr pDisplayMode = displayMode.NonConstPointer();

            return(UnsafeNativeMethods.CRhinoDisplayAttrsMgr_Add(pDisplayMode));
        }