当前位置: 首页>>代码示例>>Python>>正文


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怎么用?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 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:24,代码来源:core.py

示例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 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:17,代码来源:core.py

示例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) 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:10,代码来源:core.py


注:本文中的base.transform_point_simulation_to_canvas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。