Skip to content

Commit

Permalink
#4 simple conduit overlay test
Browse files Browse the repository at this point in the history
  • Loading branch information
moethu committed Nov 17, 2018
1 parent 0110f5c commit 3bd495c
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion Implementations/Rhino/BCF-XML/ImportCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,66 @@ 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
Plane cplane = new Plane(plane.Location, plane.Direction);
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;
}

/// <summary>
/// BCF Viewport conduit
/// </summary>
BCFConduit bcfConduit;

/// <summary>
/// Toggle BCF Conduit on and off depeding on the active viewport
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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();
}
}

/// <summary>
/// BCF Conduit
/// </summary>
class BCFConduit : Rhino.Display.DisplayConduit
{
/// <summary>
/// Title to Display
/// </summary>
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);
}
}
}


}

0 comments on commit 3bd495c

Please sign in to comment.