IliDbGrapher
Figure 4.20 The IliDbGrapher Hierarchy and Example Gadget
The
IliDbGrapher gadget lets you specify a nodes data source and a links data source. It displays the information contained in these data sources in the form of a graph.
Customizing a DbGrapher
The DbGrapher can be customized with callbacks.
The setDefineObject member function lets you specify a callback that is called when the end user attempts to create a new node. The callback is expected to fill in a table buffer with the values for the node to be created. It can open a dialog box to obtain information from the end user if needed. A similar callback for defining links can also be specified.
Here is an example:
static IlvBoolean
MyDefineNodeCallback(IliTableBuffer* buf, IlvGraphic*, IlAny any) {
static int stId = 1000;
if (buf->at("IDENTIFIER").isNull()) {
buf->at("IDENTIFIER").importInteger(stId);
stId++;
}
return IlvTrue;
}
int main() {
IliDbGrapher* gr;
...
gr->setDefineObjectCallback(MyDefineNodeCallback, NULL, IlvTrue);
...
}
The setCreateObject member function lets you specify a callback that is called when a new row has been inserted in the nodes data source. This callback is needed to create and configure the graphic object that will represent this row. A similar callback for defining links can also be specified.
Here is an example:
static IlvGraphic*
MyCreateNodeCallback(IliTableBuffer* buf, IlAny any) {
IliDbGrapher* gr = (IliDbGrapher*)any;
const char* picture;
switch (buff->at("TYPE").asInteger()) {
case TypeNodeCenter : picture = "center.xpm"; break;
case TypeNodeParabol : picture = "parabol.xpm"; break;
default : picture = "terminal.xpm"; break;
}
gr->setBitmapName((const char*)picture);
IlvGraphic* obj = gr->createDefaultObjectNode(buf);
if (obj->isSubtypeOf(IliLabeledBitmap::ClassInfo())) {
IliLabeledBitmap* node = (IliLabeledBitmap*)obj;
node->setLabelName(buff->at("NAME").getFormatted());
}
return node;
}
int main() {
IliDbGrapher* gr;
...
gr->setCreateObjectCallback(MyCreateNodeCallback, gr,IlvTrue);
...
}
There are also a NodeDoubleClicked callback and a LinkDoubleClicked callback.
Here is an example of using the NodeDoubleClicked callback:
static void
MyDoubleClickNodeCallback(IlvGraphic* g, IlAny any) {
IliDbGrapher* gr = (IliDbGrapher*)g;
const char* s = gr->getObjectNameDoubleClicked();
IlvPrint ("Node %s double clicked", (const char*)s);
}
int main() {
IliDbGrapher* gr;
...
gr->addCallback(IliDbGrapher::NodeDoubleClickedSymbol(),
MyDoubleClickNodeCallback,myPanel)
...
}
Version 5.5.1
Copyright © 2012, Rogue Wave Software, Inc. All Rights Reserved.