updated grpc node positions to use floats, avoids needing to deal with int conversions
This commit is contained in:
parent
9c302e8bc6
commit
819954a695
6 changed files with 12 additions and 33 deletions
|
@ -183,8 +183,7 @@ class CoreClient:
|
|||
)
|
||||
|
||||
def handle_exception_event(self, event):
|
||||
print(event)
|
||||
print(event.node_id)
|
||||
logging.info("exception event: %s", event)
|
||||
self.app.statusbar.core_alarms.append(event)
|
||||
|
||||
def join_session(self, session_id, query_location=True):
|
||||
|
|
|
@ -616,10 +616,7 @@ class CanvasGraph(tk.Canvas):
|
|||
if self.selected is None or self.selected in self.shapes:
|
||||
actual_x, actual_y = self.get_actual_coords(x, y)
|
||||
core_node = self.core.create_node(
|
||||
int(actual_x),
|
||||
int(actual_y),
|
||||
self.node_draw.node_type,
|
||||
self.node_draw.model,
|
||||
actual_x, actual_y, self.node_draw.node_type, self.node_draw.model
|
||||
)
|
||||
node = CanvasNode(self.master, x, y, core_node, self.node_draw.image)
|
||||
self.core.canvas_nodes[core_node.id] = node
|
||||
|
|
|
@ -140,8 +140,8 @@ class CanvasNode:
|
|||
|
||||
# set actual coords for node and update core is running
|
||||
real_x, real_y = self.canvas.get_actual_coords(x, y)
|
||||
self.core_node.position.x = int(real_x)
|
||||
self.core_node.position.y = int(real_y)
|
||||
self.core_node.position.x = real_x
|
||||
self.core_node.position.y = real_y
|
||||
if self.app.core.is_runtime() and update:
|
||||
self.app.core.edit_node(self.core_node)
|
||||
|
||||
|
@ -164,11 +164,6 @@ class CanvasNode:
|
|||
else:
|
||||
self.show_config()
|
||||
|
||||
def update_coords(self):
|
||||
x, y = self.canvas.coords(self.id)
|
||||
self.core_node.position.x = int(x)
|
||||
self.core_node.position.y = int(y)
|
||||
|
||||
def create_context(self):
|
||||
is_wlan = self.core_node.type == NodeType.WIRELESS_LAN
|
||||
is_emane = self.core_node.type == NodeType.EMANE
|
||||
|
|
|
@ -489,13 +489,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
:return: node event that contains node id, name, model, position, and services
|
||||
:rtype: core.api.grpc.core_pb2.NodeEvent
|
||||
"""
|
||||
x = None
|
||||
if event.x_position is not None:
|
||||
x = int(event.x_position)
|
||||
y = None
|
||||
if event.y_position is not None:
|
||||
y = int(event.y_position)
|
||||
position = core_pb2.Position(x=x, y=y)
|
||||
position = core_pb2.Position(x=event.x_position, y=event.y_position)
|
||||
services = event.services or ""
|
||||
services = services.split("|")
|
||||
node_proto = core_pb2.Node(
|
||||
|
|
|
@ -117,14 +117,8 @@ class NodeElement:
|
|||
|
||||
def add_position(self):
|
||||
x = self.node.position.x
|
||||
if x is not None:
|
||||
x = int(x)
|
||||
y = self.node.position.y
|
||||
if y is not None:
|
||||
y = int(y)
|
||||
z = self.node.position.z
|
||||
if z is not None:
|
||||
z = int(z)
|
||||
lat, lon, alt = None, None, None
|
||||
if x is not None and y is not None:
|
||||
lat, lon, alt = self.session.location.getgeo(x, y, z)
|
||||
|
@ -751,8 +745,8 @@ class CoreXmlReader:
|
|||
|
||||
position_element = device_element.find("position")
|
||||
if position_element is not None:
|
||||
x = get_int(position_element, "x")
|
||||
y = get_int(position_element, "y")
|
||||
x = get_float(position_element, "x")
|
||||
y = get_float(position_element, "y")
|
||||
if all([x, y]):
|
||||
options.set_position(x, y)
|
||||
|
||||
|
@ -773,8 +767,8 @@ class CoreXmlReader:
|
|||
|
||||
position_element = network_element.find("position")
|
||||
if position_element is not None:
|
||||
x = get_int(position_element, "x")
|
||||
y = get_int(position_element, "y")
|
||||
x = get_float(position_element, "x")
|
||||
y = get_float(position_element, "y")
|
||||
if all([x, y]):
|
||||
options.set_position(x, y)
|
||||
|
||||
|
|
|
@ -949,9 +949,9 @@ message SessionLocation {
|
|||
}
|
||||
|
||||
message Position {
|
||||
int32 x = 1;
|
||||
int32 y = 2;
|
||||
int32 z = 3;
|
||||
float x = 1;
|
||||
float y = 2;
|
||||
float z = 3;
|
||||
float lat = 4;
|
||||
float lon = 5;
|
||||
float alt = 6;
|
||||
|
|
Loading…
Reference in a new issue