About custom interactive objects in the viewport

For example, something simple, I imagine a circle (of fixed size, always parallel to the camera) to position defined by a Point3d, so that by rotating the camera this object rotates too (his center is the point3d), but without be a selectable or manipulatable object… So the thing is to interact with that circle, throwing mouse events or whatever, like a button for example.

It’s understandable? I can explain better if required…

The question is, is there some class in RhinoCommon for something like this? If not, is there any logical reason why that can not be done?

Thank you.

Do you know about display conduits? http://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Display_DisplayConduit.htm


Thanks for you reply Luis.
This code seems to do the work, but some things must be fixed.
I think the code can be much improved, if someone wants I’d be grateful.

Its made in a VB component of grasshopper.

Private Sub RunScript(ByVal x As Boolean, ByVal ID As Guid, ByRef A As Object) 

    If x Then
      C = New CustomIO(ID)
      c.Enabled = True
      If (C IsNot Nothing) Then c.Enabled = False
    End If
  End Sub 

  '<Custom additional code> 

  Public C As customIO

  Class CustomIO 
    Inherits Rhino.Display.DisplayConduit

    Private Radius As Integer = 30

    Private PointID As guid
    Private mc As Rhino.UI.mousecallback
    Private cts As system.Drawing.Point
    Public Clicked As Boolean
    Sub New(ID As guid)
      PointID = ID
      Clicked = False
    End Sub

    Protected Overrides Sub DrawOverlay (e As Rhino.Display.DrawEventArgs)
      'Get point.
      Dim rh As rhinoobject = e.RhinoDoc.Objects.Find(PointID)

      'Set plane parallel to camera.
      Dim pln As New plane
      Dim pt As Rhino.Geometry.point = DirectCast(rh.Geometry, Rhino.Geometry.point)
      pln.Origin = pt.Location

      Dim proy As Point3d = pt.Location
      Dim wtc As point2d = e.Viewport.WorldToClient(proy)
      cts = e.Viewport.ClientToScreen(wtc)

      If (mc Is Nothing) Then
        mc = New mymouseCallback(Me)
        mc.Enabled = True
      End If

      'Set radius in world.
      cts.X += radius
      Dim stc As system.Drawing.Point = e.Viewport.ScreenToClient(cts)
      Dim ctw As line = e.Viewport.ClientToWorld(stc)
      Dim lp As New Double
      rhino.Geometry.Intersect.Intersection.LinePlane(ctw, pln, lp)
      Dim rad As Double = pln.Origin.DistanceTo(ctw.PointAt(lp))

      'Draw circle shape.
      Dim circle As New circle(pln, Rad)
      Dim brp As brep = brep.CreatePlanarBreps(circle.ToNurbsCurve())(0)
      Dim col As color = color.DarkViolet
      If (clicked) Then
        col = color.BurlyWood
        col = color.DarkViolet
      End If
      Dim mat As New rhino.Display.DisplayMaterial(col)
      e.Display.DrawBrepShaded(brp, mat)

    End Sub

    Public Function MouseHover As Boolean
      Dim cursor As System.Drawing.Point = system.Windows.Forms.Cursor.Position
      Return math.Sqrt(((cts.X - cursor.X) ^ 2) + ((cts.Y - cursor.Y) ^ 2)) <= Radius
    End Function

  End Class

  Public Class MyMouseCallback 
    Inherits Rhino.UI.MouseCallback

    Private _CustomIO As CustomIO

    Sub New(CIO As customIO)
      _CustomIO = CIO
    End Sub

    Protected Overrides Sub OnMouseDown(e As Rhino.UI.MouseCallbackEventArgs)
      If (_CustomIO.MouseHover) Then
        _CustomIO.Clicked = Not _CustomIO.Clicked 
        RhinoApp.WriteLine("HECHO" & Date.now().ToString())
      End If
    End Sub
  End Class

  '</Custom additional code> 
End Class

EDIT* Why some parts are in red? o.O