本文整理汇总了Python中base.transform_point_simulation_to_canvas方法的典型用法代码示例。如果您正苦于以下问题:Python base.transform_point_simulation_to_canvas方法的具体用法?Python base.transform_point_simulation_to_canvas怎么用?Python base.transform_point_simulation_to_canvas使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类base
的用法示例。
在下文中一共展示了base.transform_point_simulation_to_canvas方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: node_drag_motion
# 需要导入模块: import base [as 别名]
# 或者: from base import transform_point_simulation_to_canvas [as 别名]
def node_drag_motion(self, item, targe_item, event, node):
self.simulation.lock.acquire()
try:
ns3_node = ns.network.NodeList.GetNode(node.node_index)
mob = ns3_node.GetObject(ns.mobility.MobilityModel.GetTypeId())
if mob is None:
return False
if self.node_drag_state is None:
return False
x, y, dummy = self.canvas.window.get_pointer()
canvas_x, canvas_y = self.canvas.convert_from_pixels(x, y)
dx = (canvas_x - self.node_drag_state.canvas_x0)
dy = (canvas_y - self.node_drag_state.canvas_y0)
pos = mob.GetPosition()
pos.x = self.node_drag_state.sim_x0 + transform_distance_canvas_to_simulation(dx)
pos.y = self.node_drag_state.sim_y0 + transform_distance_canvas_to_simulation(dy)
#print "SetPosition(%G, %G)" % (pos.x, pos.y)
mob.SetPosition(pos)
node.set_position(*transform_point_simulation_to_canvas(pos.x, pos.y))
finally:
self.simulation.lock.release()
return True
示例2: _update_node_positions
# 需要导入模块: import base [as 别名]
# 或者: from base import transform_point_simulation_to_canvas [as 别名]
def _update_node_positions(self):
for node in self.nodes.itervalues():
if node.has_mobility:
ns3_node = ns.network.NodeList.GetNode(node.node_index)
mobility = ns3_node.GetObject(ns.mobility.MobilityModel.GetTypeId())
if mobility is not None:
pos = mobility.GetPosition()
x, y = transform_point_simulation_to_canvas(pos.x, pos.y)
node.set_position(x, y)
if node is self.follow_node:
hadj = self._scrolled_window.get_hadjustment()
vadj = self._scrolled_window.get_vadjustment()
px, py = self.canvas.convert_to_pixels(x, y)
hadj.value = px - hadj.page_size/2
vadj.value = py - vadj.page_size/2
示例3: set_bounds
# 需要导入模块: import base [as 别名]
# 或者: from base import transform_point_simulation_to_canvas [as 别名]
def set_bounds(x1, y1, x2, y2):
assert x2>x1
assert y2>y1
def hook(viz):
cx1, cy1 = transform_point_simulation_to_canvas(x1, y1)
cx2, cy2 = transform_point_simulation_to_canvas(x2, y2)
viz.canvas.set_bounds(cx1, cy1, cx2, cy2)
add_initialization_hook(hook)