Building a custom circuit renderer

49 views
Skip to first unread message

Vijay Dirisala

unread,
Mar 18, 2015, 6:08:06 PM3/18/15
to authoring-to...@googlegroups.com
Hi,

First off thanks for all the great work on this framework! Pretty awesome that you guys decided to open source it on top of that!

The CircuitEditor sample is a great way to get started. I have a few questions on this topic. The element nodes used in the sample are very simple. If I wanted to use more complex element nodes (nodes with a lot of state - lots of attributes, potentially different categories of attributes, and such) and needed some of this extra state to be rendered, it seems like I'd have to pretty much take on the entire rendering process myself. Is that correct? It seems like I'd create a class derived from D2dCircuitRenderer and implement the various Draw() methods in it. Since most functionality in D2dCircuitRenderer is private there isn't a whole lot I can reuse from there. So does it even make sense to derive from it? Maybe deriving my custom renderer from G2dGraphRenderer maybe a better option in this case? Although D2dCircuitRender is still good for all the grouping as well as interactive abilities it has. Is all of my understanding correct or am I missing anything?

In some of the demo videos and presentations I've seen applications similar to the CircuitEditor that had quite elaborate and complex graph nodes being drawn on screen. I'm assuming most of these applications took an approach similar to the above, where they manage the entire rendering of elements/nodes themselves?

Thanks in advance,
Vijay

Ron AtSony

unread,
Mar 18, 2015, 6:34:39 PM3/18/15
to Vijay Dirisala, authoring-to...@googlegroups.com
Hi Vijay,

You're welcome and I hope ATF proves useful to you.

One first-party client who created a heavily customized version of CircuitEditor did derive from D2dCircuitRenderer and overrode these methods:
  • public override void Draw(CircuitElement inElement, DiagramDrawingStyle inStyle, D2dGraphics inG)
  • protected override D2dBrush GetPen(Pin pin)
  • public override void Draw(Wire inWire, DiagramDrawingStyle inStyle, D2dGraphics inG)
  • public override void Draw(CircuitElement inOutputElement, Pin inOutputPin, CircuitElement inInputElement, Pin inInputPin, string inLabel, Point inEndPoint, D2dGraphics inG)
  • public override void OnGraphObjectChanged(object sender, ItemChangedEventArgs<object> e)
  • public override RectangleF GetBounds(CircuitElement inElement, D2dGraphics inG)
  • public override int GetPinOffset(ICircuitElement inElement, int inPinIndex, bool inInputSide)
  • protected override bool Pick(CircuitElement inElement, D2dGraphics inG, PointF inP)
  • protected override bool PickEdge(Wire inWire, PointF inPoint, D2dGraphics inG, float xOffset = 0, float yOffset = 0)
  • protected override ElementSizeInfo GetElementSizeInfo(ICircuitElementType inType, D2dGraphics inG, string title = null)
(These methods were from a version of ATF from about a year ago, plus they had a forked version of ATF, so I can't promise that these methods are exactly the same in the current version.)

This did generate a lot of duplicate code. There's no easy alternative at the moment. For example, we don't have anything like a scene graph or container system where you could insert custom parts for each circuit element.

Can you give us some examples of the kinds of extra state that you wish to render? For example, do you envision each circuit element as a little property editor, with property editing controls (check boxes, text editors, sliders, etc.)?

--Ron


--
You received this message because you are subscribed to the Google Groups "Authoring Tools Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to authoring-tools-fr...@googlegroups.com.
Visit this group at http://groups.google.com/group/authoring-tools-framework.
For more options, visit https://groups.google.com/d/optout.

Vijay Dirisala

unread,
Mar 20, 2015, 3:21:00 PM3/20/15
to authoring-to...@googlegroups.com, tec...@gmail.com
Thanks for the information. I have a number of different areas I'd like to use this framework for. One specific area is a UML-like model builder, where each graph node is a class with attributes, methods, events, and such. Viewing each node as a little property editor is an interesting idea. With some sort of grouping for these properties and the ability to collapse/expand individual groups of properties could probably get me close to some of these use cases. Ultimately though, depending on the specific application in mind, having to render our own nodes is not a big deal. As long as the framework is flexible enough to enable that implementation where necessary (and still have all the editor features work the same) then that'd be a huge win. I hope that helps.
To unsubscribe from this group and stop receiving emails from it, send an email to authoring-tools-framework+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages