1 from __future__
import print_function
2 import ns.point_to_point
11 from gi.repository
import GObject
15 PIXELS_PER_METER = 3.0
20 __gtype_name__ =
"PyVizObject"
27 tooltip.set_text(
"TODO: tooltip for %r" % self)
40 raise NotImplementedError
49 def __init__(self, is_wireless=None, is_virtual=False):
52 @param self The current class
53 @param is_wireless is wireless flag
54 @param is_virtual is virtual flag
56 assert is_virtual
or is_wireless
is not None
61 ns.point_to_point.PointToPointNetDevice:
NetDeviceTraits(is_wireless=
False),
65 ns.internet.LoopbackNetDevice:
NetDeviceTraits(is_virtual=
True, is_wireless=
False),
75 return netdevice_traits[class_type]
77 sys.stderr.write(
"WARNING: no NetDeviceTraits registered for device type %r; "
78 "I will assume this is a non-virtual wireless device, "
79 "but you should edit %r, variable 'netdevice_traits',"
80 " to make sure.\n" % (class_type.__name__, __file__))
82 netdevice_traits[class_type] = t
86 return d*PIXELS_PER_METER
89 return x*PIXELS_PER_METER, y*PIXELS_PER_METER
92 return d/PIXELS_PER_METER
95 return x/PIXELS_PER_METER, y/PIXELS_PER_METER
107 @param plugin: a callable object that will be invoked whenever a
108 Visualizer object is created, like this: plugin(visualizer)
110 assert callable(plugin_init_func)
111 plugins.append(plugin_init_func)
112 if plugin_module
is not None:
113 plugin_modules[plugin_name] = plugin_module
115 plugins_loaded =
False
117 global plugins_loaded
120 plugins_loaded =
True
121 plugins_dir = os.path.join(os.path.dirname(__file__),
'plugins')
122 old_path =
list(sys.path)
123 sys.path.insert(0, plugins_dir)
124 for filename
in os.listdir(plugins_dir):
125 name, ext = os.path.splitext(filename)
129 plugin_module = __import__(name)
130 except ImportError
as ex:
131 print(
"Could not load plugin %r: %s" % (filename, str(ex)), file=sys.stderr)
134 plugin_func = plugin_module.register
135 except AttributeError:
136 print(
"Plugin %r has no 'register' function" % name, file=sys.stderr)
def __init__(self, is_wireless=None, is_virtual=False)
Initialize function.
is_wireless
class variablesis wireless
def tooltip_query(self, tooltip)
Returns tooltip text string.
def transform_distance_simulation_to_canvas(d)
def register_plugin(plugin_init_func, plugin_name=None, plugin_module=None)
def transform_distance_canvas_to_simulation(d)
def transform_point_canvas_to_simulation(x, y)
def lookup_netdevice_traits(class_type)
def transform_point_simulation_to_canvas(x, y)