Graph Layout > Using Advanced Features > Using the Filtering Features to Lay Out a Part of an IlvGrapher > Filtering by Graphic Objects
 
Filtering by Graphic Objects
The nodes and links to be taken into account during the layout can also be filtered individually. To do this, a custom subclass of IlvLayoutGraphicFilter must be written. The filtering rules have to be embedded in the overridden implementation of the accept method. For example, user properties could be used by an application to “mark” nodes and links that have to be accepted by the filter. The filter class could then be written as follows. In this example, the name of the property is stored in the variable FILTER_PROP.
class LayoutFilter
: public IlvLayoutGraphicFilter
{
public:
LayoutFilter()
{
}
IlBoolean accept(IlvGraphic* obj)
{
IlAny prop = obj->getProperty(IlGetSymbol(FILTER_PROP));
if (!prop)
return IlFalse;
// accept a link only if its two end-nodes are accepted
if (obj->isSubtypeOf(IlvLinkImage::ClassInfo()->getClassName())) {
IlvLinkImage* link = (IlvLinkImage*)obj;
return (link->getFrom()->getProperty(IlGetSymbol(FILTER_PROP)) &&
link->getTo()->getProperty(IlGetSymbol(FILTER_PROP)));
}
return IlTrue;
}
};
 

Version 6.1
Copyright © 2016, Rogue Wave Software, Inc. All Rights Reserved.