From 3bd495ceaa117e23e5c0c723a340f59557afe6bc Mon Sep 17 00:00:00 2001 From: moethu Date: Sat, 17 Nov 2018 17:24:39 +0100 Subject: [PATCH] #4 simple conduit overlay test --- .../Rhino/BCF-XML/ImportCommand.cs | 50 ++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Implementations/Rhino/BCF-XML/ImportCommand.cs b/Implementations/Rhino/BCF-XML/ImportCommand.cs index e6c6d2f5..59e17aff 100644 --- a/Implementations/Rhino/BCF-XML/ImportCommand.cs +++ b/Implementations/Rhino/BCF-XML/ImportCommand.cs @@ -119,7 +119,7 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) vp.SetCameraDirection(cam.Direction, true); vp.Name = System.IO.Path.GetFileNameWithoutExtension(bcfv); doc.NamedViews.Add(vp.Name, vp.Id); - + foreach (XMLClippingPlane plane in planes) { double magnitude = 100; // not sure if this value makes much sense @@ -127,10 +127,58 @@ protected override Result RunCommand(RhinoDoc doc, RunMode mode) doc.Objects.AddClippingPlane(cplane, magnitude, magnitude, vp.Id); } + bcfConduit = new BCFConduit(); + bcfConduit.Title = vp.Name; + bcfConduit.Enabled = true; view.Redraw(); } + Rhino.Display.RhinoView.SetActive += RhinoView_SetActive; + return Result.Success; } + + /// + /// BCF Viewport conduit + /// + BCFConduit bcfConduit; + + /// + /// Toggle BCF Conduit on and off depeding on the active viewport + /// + /// + /// + private void RhinoView_SetActive(object sender, Rhino.Display.ViewEventArgs e) + { + if (e.View.ActiveViewport.Name.Contains("Viewpoint")) + bcfConduit.Enabled = true; + else + bcfConduit.Enabled = false; + e.View.Document.Views.Redraw(); + } + } + + /// + /// BCF Conduit + /// + class BCFConduit : Rhino.Display.DisplayConduit + { + /// + /// Title to Display + /// + public string Title = "Untitled"; + + protected override void DrawForeground(Rhino.Display.DrawEventArgs e) + { + // Draw only on top of BCF Viewpoints + if (e.Viewport.Name.Contains("Viewpoint")) + { + var bounds = e.Viewport.Bounds; + var pt = new Rhino.Geometry.Point2d(bounds.Right - 100, bounds.Bottom - 30); + e.Display.Draw2dText(Title, System.Drawing.Color.Red, pt, false); + } + } } + + }