Monday, December 27, 2010

Notification Tree - a Sneak Peak

As work continues on Solver displaying (I have a problem on displaying the same behavior using document based drawing), I've did another small gift for external developers: NotificationTree.
What is it useful?
The idea comes from using D-Bus (where you register and notify based on paths). We picked this extra input for cases that NaroCAD cannot solve. I am talking aloud some cases that NaroCAD will not be able to solve with it's actual design: supposedly there is an operation over the network, or running in an external process, and you switch your working action in the meantime as you wait for result in design mode. How can you get back notified? You want to notify a component that is not defined nicely in your design in NaroCAD framework and integration is too hard to be done: NaroCAD integrates click tree with selection, which is great for users, but if you will want to extend, change the code as it goes with mouse clicks, or you want your ribbon state to change on solver changes, you did had no methods to do it as you mostly can get only life-cycle notifications and you will have to be too hacky in our code-base to do your work.
Just if you have those cases, and you looked to NaroCAD code-base and you did not know where to start, right now is fairly easy:
- try to make a plugin, start from TwoPointLine plugin that is provided with NaroCAD
- try to instantiate inputs. Try to get the NotificationTreeInput instance and use the GetValue to get a document from it
- try to register a notification using: Document. Root. Set<NotificationInterpreter>(). RegisterPath("MyComponent/OnMyEvent", OnMyEventHandler) where
void OnMyEventHandler(Node pathNode)
(...) //your code
To call this code, you can call it like this:
Document. Root. Set<NotificationInterpreter>(). NotifyPath("MyComponent/OnMyEvent");
This code will mainly mean to you that you will be able to extend NaroCAD with all events that are given.
As events are called, there is internal propagation logic that you can use it to monitor subpaths, this will not be wrapped as it appear to me to be also a hacky way to do it, but anyway, the main idea is that if you feel that are limitations on NaroCAD level, it may be easier as of today to overcome them.

No comments: