Modify host icon dynamically

17 views
Skip to first unread message

Johnny Peav

unread,
Jun 27, 2016, 6:09:39 AM6/27/16
to OMNeT++ Users
Hi all,

Do you know how could it be modified the icon of a host dynamically? 

I know how to load an icon from code:

        cIconFigure *icon = new cIconFigure("icon");
        icon->setPosition(cFigure::Point(100,100));
        icon->setImageName("block/sink");
        icon->setTintColor(cFigure::Color("gold"));
        icon->setTintAmount(0.6);
        icon->setOpacity(0.8);

But I don't know how to assign this cIconFigure instance to a host.

Any help is welcome.

Thanks!!

Rudolf Hornig

unread,
Jun 28, 2016, 4:16:08 AM6/28/16
to OMNeT++ Users
The default module icons are special in OMNeT++5. You can manipulate them with the old getDisplaysString()/setTag() API. Changing the icon is pretty straightforward: set thefirst argument of i tag in the module's displaystring.

The new API (that you were trying is just for anything else you want to draw on the canvas).

ps: we were considering replacing the old icon code with the new API making the whole UI much more versatile and also uniform, but at the end we have dropped that for OMNeT++ 5 because it would have introduced too much incompatibilities...
Reply all
Reply to author
Forward
0 new messages