Grasshopper

algorithmic modeling for Rhino

Dear all, dear David

I have been searching but could not get my hands on a way to add figures above the canvas form like what happens when the solving is disabled:

I would like to achieve something quite similar (a thick border + an icon, when something dangerous is happening...), so I suppose it would be the same method than the one used for the disabled solver, but I have no idea where to begin.

So, thanks in advance if somebody has a clue... 

Thibault.

Views: 516

Replies to This Discussion

Well, it can be done, though not in the exact same way as the Disabled Solver graphics. The canvas draws stuff in distinct layers (or "channels") and there are events for each channel that you can handle and draw custom stuff.

These are all the events that are generated given a typical Canvas painting procedure:

  1. CanvasPaintBegin
  2. CanvasPaintBackground
  3. CanvasPrePaintGroups
  4. CanvasPostPaintGroups
  5. CanvasPrePaintWires
  6. CanvasPostPaintWires
  7. CanvasPrePaintObjects
  8. CanvasPostPaintObjects
  9. CanvasPrePaintOverlay
  10. CanvasPostPaintOverlay
  11. CanvasPrePaintWidgets
  12. CanvasPostPaintWidgets
  13. CanvasPaintEnd

As you can see quite a few events. I hope the names are self-documenting enough for you to guess what sort of painting goes on in between these events.

You'll want to draw your stuff way at the end so that it doesn't end up underneath any other objects. You can handle CanvasPostPaintWidgets for this (CanvasPaintEnd is too late to start drawing stuff).

Another approach would be to create a custom Widget. The downside of this one is that other widgets (compass, markov chain etc.) may be drawn on top of you. The upside though is that you get to handle mouse events so when someone clicks on your border or icon you can 'eat' the click.

Do you need further example code?

--

David Rutten

david@mcneel.com

Poprad, Slovakia

I implemented the CanvasPostPaintWidgets event approach in the attached file.

--

David Rutten

david@mcneel.com

Tirol, Austria

Attachments:

Wow

That was fast!

It's exactly what I needed, huge thanks, this is a great example!

Have a nice evening!

Thibault.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service