Python base.transform_point_simulation_to_canvas() Examples

The following are 30 code examples of base.transform_point_simulation_to_canvas(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module base , or try the search function .
Example #1
Source File: core.py    From ntu-dsi-dcn with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #2
Source File: core.py    From Tocino with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #3
Source File: core.py    From ns3-802.11ad with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #4
Source File: core.py    From ns3-ecn-sharp with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #5
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #6
Source File: core.py    From ns-3-dev-git with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #7
Source File: core.py    From royal-chaos with MIT License 6 votes vote down vote up
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 
Example #8
Source File: core.py    From ns3-rdma with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #9
Source File: core.py    From 802.11ah-ns3 with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #10
Source File: core.py    From ns3-load-balance with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #11
Source File: core.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 6 votes vote down vote up
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 
Example #12
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #13
Source File: core.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #14
Source File: core.py    From ntu-dsi-dcn with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #15
Source File: core.py    From Tocino with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #16
Source File: core.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #17
Source File: core.py    From ntu-dsi-dcn with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #18
Source File: core.py    From ns3-802.11ad with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #19
Source File: core.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #20
Source File: core.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #21
Source File: core.py    From ns3-ecn-sharp with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #22
Source File: core.py    From CRE-NS3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #23
Source File: core.py    From 802.11ah-ns3 with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #24
Source File: core.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #25
Source File: core.py    From IEEE-802.11ah-ns-3 with GNU General Public License v2.0 5 votes vote down vote up
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) 
Example #26
Source File: core.py    From ns-3-dev-git with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #27
Source File: core.py    From royal-chaos with MIT License 5 votes vote down vote up
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) 
Example #28
Source File: core.py    From ns3-load-balance with GNU General Public License v2.0 5 votes vote down vote up
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 
Example #29
Source File: core.py    From royal-chaos with MIT License 5 votes vote down vote up
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 
Example #30
Source File: core.py    From ns3-rdma with GNU General Public License v2.0 5 votes vote down vote up
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)