Grasshopper

algorithmic modeling for Rhino

I would like to render them differently, but I do something wrong.

Protected Overrides Sub Render(canvas As GH_Canvas, graphics As Drawing.Graphics, channel As GH_CanvasChannel)

Select Case channel

Case GH_CanvasChannel.Wires


RenderIncomingWires(canvas.Painter, Owner.Params.Input(0).Sources, Grasshopper.Kernel.GH_ParamWireDisplay.faint)


Case Else


MyBase.Render(canvas, graphics, channel)


End Select

End Sub

This results in no wires displayed. I know that I can draw them as fainted with Params.Input(0).WireDisplay =  GH_ParamWireDisplay.faint but I want to change their pen later... (for now I just try to do anything with them).

Views: 1351

Replies to This Discussion

The component doesn't draw wires, the parameters do. You're going to have to either provide unique attributes for the input parameters as well, or you're going to have to iterate over all inputs, then iterate over all the sources for each input and draw the wire you want.

Out of curiosity, why do you want to draw different wires?

--

David Rutten

david@mcneel.com

Thanks, that clears a lot.

I have 2 components (Anemone plugin) which don't work when not connected together, also this one wire is a fake representation for the user telling him that data goes backwards. I'm looking for a good way to make it clear for the user that this connection is different than usual.

I'm not yet sure if I really want to break the drawing logic that way. I may only change the component color a bit cause I found that it may be easier to find them on the canvas (and this is quite crucial as they are in control of whole definition.. one resets the setup, the other one pauses the loop).

In the picture you can see those 2 components with black background (group), and how much it clears the view of the loop here (this particular def does boids). Also the one wire which I'm thinking about is the one which goes from the one "black" to the another "black".

I try to follow a bit the default logic - like when some component doesn't exactly fit the usual behavior, it's drawn a bit different... Galapagos is pink (? don't ask me about colors, I have to use color picker a lot), panel is yellow, slider has some light grey background etc.

I was not able to do what you actually said, but I've stitched some parts of your code and tried to draw something. Don't really know if thats a good option (fainted wire with dots on it), I think it'll be better to just set the wire by default to fainted (that way being closer to Galapagos) and do not overcomplicate the GH drawing style.

I attached an attributes class which draws the wires from the first parameter in a custom pen but the rest are drawn normally.

Galapagos is different because the wires don't actually transport any data, they are like the Timer object wire, it's just the visual representation of one object being aware of another object. Since that sort of seems to be the case here as well, I suppose custom wires make sense.

--

David Rutten

david@mcneel.com

Attachments:

Thank you, seems much easier than what I though.

Another question - if I want to change component's color, do I have to redraw it from scratch ? I can draw a simple standard capsule, but I want to be able to add more inputs/outputs and I could not find a method to draw the +/- buttons.

EDIT : Is there a way to somehow catch the default capsule drawing in Render and change its properties ?

You cannot modify the capsule used by the default attributes. It is created, drawn and destroyed within the Render method. You can add grips using the GH_Capsule.AddInputGrip and AddOutputGrip methods. I recommend using the overloads which only use a y-value instead of a complete point, let the capsule figure out what the x-value should be.

Don't modify the InputGrips and OutputGrips lists on GH_Capsule, that way madness lies.

If you want to change the colour, you have only 2 options, neither of them ideal:

  1. Draw it from scratch.
  2. Modify the default colours, call the base-class (so it actually draws in whatever colour you want) then restore the default.

All the default styles are stored in GH_Skin, but there's no way to easily set a restore point on this class, so you're going to have to do the caching yourself. I'd prefer this second method, just be sure to put a try...finally block around your code so you're certain to restore the normal colours.

--

David Rutten

david@mcneel.com

These are the ones typically used by all capsules btw, depending on the state of the component:

Public palette_normal_standard As GH_PaletteStyle

Public palette_normal_selected As GH_PaletteStyle

Public palette_hidden_standard As GH_PaletteStyle

Public palette_hidden_selected As GH_PaletteStyle

Public palette_locked_standard As GH_PaletteStyle

Public palette_locked_selected As GH_PaletteStyle

Public palette_warning_standard As GH_PaletteStyle

Public palette_warning_selected As GH_PaletteStyle

Public palette_error_standard As GH_PaletteStyle

Public palette_error_selected As GH_PaletteStyle

--

David Rutten

david@mcneel.com

As for today this is the point where it got to. After some trials and errors I managed to "reverse engineer" the highlight gradient. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service