public override bool ExecConduit(ref MRhinoDisplayPipeline pipeline, uint channel, ref bool terminate) { if (MSupportChannels.SC_CALCBOUNDINGBOX == channel) { // If you are dynamically drawing objects, then we must implement the // this channel to add to the overall scene bounding box. This will make // Rhino adjust its clipping planes to include our geometry. for (int i = 0; i < m_objects.Count; i++) { IRhinoObject obj = m_objects[i]; if (null != obj) { OnBoundingBox bbox = obj.BoundingBox(); bbox.Transform(m_xform); m_pChannelAttrs.m_BoundingBox.Union(bbox); } } } else if (MSupportChannels.SC_DRAWOVERLAY == channel) { // This channel is where the drawing takes place. for (int i = 0; i < m_objects.Count; i++) { IRhinoObject obj = m_objects[i]; if (null != obj) { pipeline.SetObjectColor(obj.ObjectDrawColor()); pipeline.DrawObject(obj, m_xform); } } } return(true); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { if (null != m_brep) { MRhinoViewport vp = dp.GetRhinoVP(); OnColor saved_color = vp.SetDrawColor(RhUtil.RhinoApp().AppSettings().TrackingColor()); for (int i = 0; i < m_points.Count(); i++) { if (i % 100 == 0 && vp.InterruptDrawing()) { break; } On3dPoint pt = m_points[i]; On3dVector dir = new On3dVector(m_normals[i]); if (m_bFlip) { dir.Reverse(); } vp.DrawDirectionArrow(pt, dir); } vp.SetDrawColor(saved_color); } } return(true); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOBJECT) { if (null != m_pChannelAttrs.m_pObject) { if (m_pChannelAttrs.m_pObject.m_runtime_object_serial_number == m_runtime_object_serial_number) { if (null == m_mesh_face_colors) { IRhinoMeshObject mesh_object = MRhinoMeshObject.ConstCast(m_pChannelAttrs.m_pObject); if (null != mesh_object) { int mesh_face_count = mesh_object.Mesh().FaceCount(); m_mesh_face_colors = new ArrayOnColor(mesh_face_count); for (int i = 0; i < mesh_face_count; i++) { OnColor color = new OnColor(m_random.Next(0, 255), m_random.Next(0, 255), m_random.Next(0, 255)); m_mesh_face_colors.Append(color); } } } if (null != m_mesh_face_colors) { m_pChannelAttrs.m_bDrawObject = false; MDisplayPipelineAttributes da = new MDisplayPipelineAttributes(); da.m_bShadeSurface = true; da.m_pMaterial.m_FrontMaterial.SetTransparency(0.0); da.m_pMaterial.m_BackMaterial.SetTransparency(0.0); da.m_pMaterial.m_FrontMaterial.m_bFlatShaded = true; da.m_pMaterial.m_BackMaterial.m_bFlatShaded = true; dp.EnableDepthWriting(true); if (da.m_bCullBackfaces) { dp.PushCullFaceMode(1); } for (int i = 0; i < m_mesh_face_colors.Count(); i++) { da.m_pMaterial.m_FrontMaterial.m_diffuse = m_mesh_face_colors[i]; da.m_pMaterial.m_BackMaterial.m_diffuse = m_mesh_face_colors[i]; dp.DrawFace(m_pChannelAttrs.m_pObject, i, da); } if (da.m_bCullBackfaces) { dp.PopCullFaceMode(); } } } } } return(true); }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (null == view) { return(IRhinoCommand.result.failure); } MRhinoViewport vp = view.ActiveViewport(); MRhinoDisplayPipeline dp = view.DisplayPipeline(); MDisplayPipelineAttributes da = view.DisplayAttributes(); // Prevent capturing of the frame buffer on every update MRhinoDisplayPipeline.EnableFrameBufferCapture(false); // Prevent the draw list from updating on every frame dp.FreezeDrawing(true); int dir = 0; // 0 = Right, 1 = Left, 2 = Down, and 3 = Up int frame_count = 100; double delta_angle = 5.0 * (Math.PI / 180.0); for (int i = 0; i < frame_count; i++) { switch (dir) { case 0: vp.LeftRightRotate(delta_angle); break; case 1: vp.LeftRightRotate(-delta_angle); break; case 2: vp.DownUpRotate(delta_angle); break; case 3: vp.DownUpRotate(-delta_angle); break; } //dp.DrawFrameBuffer(da); view.Redraw(); RhUtil.RhinoApp().Wait(0); } dp.FreezeDrawing(false); MRhinoDisplayPipeline.EnableFrameBufferCapture(true); view.Redraw(); return(IRhinoCommand.result.success); }
///////////////////////////////////////////////////////////////////////// // Overridden MRhinoGetPoint::DynamicDraw public override void DynamicDraw(IntPtr hdc, MRhinoViewport vp, IOn3dPoint pt) { MRhinoDisplayPipeline dp = vp.DisplayPipeline(); if (dp != null) { dp.PushObjectColor(0); dp.DrawObjects(m_list.m_objects, m_xform); dp.DrawObjects(m_list.m_grip_owners); dp.PopObjectColor(); base.DynamicDraw(hdc, vp, pt); } }
/// <summary> /// Virtual MRhinoDisplayConduit.ExecConduit override /// </summary> public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX) { m_pChannelAttrs.m_BoundingBox.Union(m_line.BoundingBox()); } else if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { dp.DrawLine(m_line.from, m_line.to, m_pDisplayAttrs.m_ObjectColor | 0xFF000000, m_pDisplayAttrs.m_nLineThickness); if (m_bDraw) { dp.DrawPolygon(m_arrowhead, dp.DisplayAttrs().m_ObjectColor | 0xFF000000, true); } } return(true); }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX) { MRhinoViewport vp = dp.GetRhinoVP(); OnCircle circle = new OnCircle(); if (CalculateCircle(vp, ref circle)) m_pChannelAttrs.m_BoundingBox.Union(circle.BoundingBox()); } else if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { MRhinoViewport vp = dp.GetRhinoVP(); OnCircle circle = new OnCircle(); if (CalculateCircle(vp, ref circle)) vp.DrawCircle(circle); } return true; }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX) { MRhinoViewport vp = dp.GetRhinoVP(); OnCircle circle = new OnCircle(); if (CalculateCircle(vp, ref circle)) { m_pChannelAttrs.m_BoundingBox.Union(circle.BoundingBox()); } } else if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { MRhinoViewport vp = dp.GetRhinoVP(); OnCircle circle = new OnCircle(); if (CalculateCircle(vp, ref circle)) { vp.DrawCircle(circle); } } return(true); }
/// <summary> /// Virtual MRhinoDisplayConduit.ExecConduit override /// </summary> public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_CALCBOUNDINGBOX) { m_pChannelAttrs.m_BoundingBox.Union(m_line.BoundingBox()); } else if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { dp.DrawLine(m_line.from, m_line.to, m_pDisplayAttrs.m_ObjectColor | 0xFF000000, m_pDisplayAttrs.m_nLineThickness); if (m_bDraw) dp.DrawPolygon(m_arrowhead, dp.DisplayAttrs().m_ObjectColor | 0xFF000000, true); } return true; }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOBJECT) { if (null != m_pChannelAttrs.m_pObject) { if (m_pChannelAttrs.m_pObject.m_runtime_object_serial_number == m_runtime_object_serial_number) { if (null == m_mesh_face_colors) { IRhinoMeshObject mesh_object = MRhinoMeshObject.ConstCast(m_pChannelAttrs.m_pObject); if (null != mesh_object) { int mesh_face_count = mesh_object.Mesh().FaceCount(); m_mesh_face_colors = new ArrayOnColor(mesh_face_count); for (int i = 0; i < mesh_face_count; i++) { OnColor color = new OnColor(m_random.Next(0, 255), m_random.Next(0, 255), m_random.Next(0, 255)); m_mesh_face_colors.Append(color); } } } if (null != m_mesh_face_colors) { m_pChannelAttrs.m_bDrawObject = false; MDisplayPipelineAttributes da = new MDisplayPipelineAttributes(); da.m_bShadeSurface = true; da.m_pMaterial.m_FrontMaterial.SetTransparency(0.0); da.m_pMaterial.m_BackMaterial.SetTransparency(0.0); da.m_pMaterial.m_FrontMaterial.m_bFlatShaded = true; da.m_pMaterial.m_BackMaterial.m_bFlatShaded = true; dp.EnableDepthWriting(true); if (da.m_bCullBackfaces) dp.PushCullFaceMode(1); for (int i = 0; i < m_mesh_face_colors.Count(); i++) { da.m_pMaterial.m_FrontMaterial.m_diffuse = m_mesh_face_colors[i]; da.m_pMaterial.m_BackMaterial.m_diffuse = m_mesh_face_colors[i]; dp.DrawFace(m_pChannelAttrs.m_pObject, i, da); } if (da.m_bCullBackfaces) dp.PopCullFaceMode(); } } } } return true; }
public override bool ExecConduit(ref MRhinoDisplayPipeline pipeline, uint channel, ref bool terminate) { if (MSupportChannels.SC_CALCBOUNDINGBOX == channel) { // If you are dynamically drawing objects, then we must implement the // this channel to add to the overall scene bounding box. This will make // Rhino adjust its clipping planes to include our geometry. for (int i = 0; i < m_objects.Count; i++) { IRhinoObject obj = m_objects[i]; if (null != obj) { OnBoundingBox bbox = obj.BoundingBox(); bbox.Transform(m_xform); m_pChannelAttrs.m_BoundingBox.Union(bbox); } } } else if (MSupportChannels.SC_DRAWOVERLAY == channel) { // This channel is where the drawing takes place. for (int i = 0; i < m_objects.Count; i++) { IRhinoObject obj = m_objects[i]; if (null != obj) { pipeline.SetObjectColor(obj.ObjectDrawColor()); pipeline.DrawObject(obj, m_xform); } } } return true; }
public override bool ExecConduit(ref MRhinoDisplayPipeline dp, uint nChannel, ref bool bTerminate) { if (nChannel == MSupportChannels.SC_DRAWOVERLAY) { if (null != m_brep) { MRhinoViewport vp = dp.GetRhinoVP(); OnColor saved_color = vp.SetDrawColor(RhUtil.RhinoApp().AppSettings().TrackingColor()); for (int i = 0; i < m_points.Count(); i++) { if (i % 100 == 0 && vp.InterruptDrawing()) break; On3dPoint pt = m_points[i]; On3dVector dir = new On3dVector(m_normals[i]); if (m_bFlip) dir.Reverse(); vp.DrawDirectionArrow(pt, dir); } vp.SetDrawColor(saved_color); } } return true; }
///<summary> This gets called when when the user runs this command.</summary> public override IRhinoCommand.result RunCommand(IRhinoCommandContext context) { MRhinoView view = RhUtil.RhinoApp().ActiveView(); if (view == null) { return(IRhinoCommand.result.nothing); } MRhinoGetOption go = new MRhinoGetOption(); go.SetCommandPrompt("Capture Method"); go.SetCommandPromptDefault("ViewCapture"); int viewcap = go.AddCommandOption(new MRhinoCommandOptionName("ViewCapture")); int screencap = go.AddCommandOption(new MRhinoCommandOptionName("ScreenCapture")); go.GetOption(); if (go.CommandResult() != IRhinoCommand.result.success) { return(go.CommandResult()); } System.Drawing.Bitmap bmp = null; if (go.Option().m_option_index == viewcap) { MRhinoDisplayPipeline pipeline = view.DisplayPipeline(); int left = 0, right = 0, bot = 0, top = 0; view.MainViewport().VP().GetScreenPort(ref left, ref right, ref bot, ref top); int w = right - left; int h = bot - top; bmp = new System.Drawing.Bitmap(w, h); System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp); MDisplayPipelineAttributes attr = new MDisplayPipelineAttributes(pipeline.DisplayAttrs()); bool rc = pipeline.DrawToDC(g, w, h, attr); g.Dispose(); if (!rc) { bmp = null; } } else { bmp = new System.Drawing.Bitmap(1, 1); bool rc = view.ScreenCaptureToBitmap(ref bmp, true, false); if (!rc) { bmp = null; } } if (bmp != null) { string mydir = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments); string path = System.IO.Path.Combine(mydir, "capture.png"); bmp.Save(path); return(IRhinoCommand.result.success); } return(IRhinoCommand.result.failure); }