def select_vertex(direction, prefix): index = index_of_vertex(vertex.name) # If the opponent user is not grabbing the vertex already try: surface.select(vertex.name) vertex.color = COLOR_GEOMETRY_LITE self.text.write( '{PREFIX}Vertex #{INDEX} selected'.format( PREFIX = prefix, INDEX = index)) # If the opponent user is grabbing the vertex except VertexLocked: self.text.write( '{PREFIX}Vertex #{INDEX} is locked'.format( PREFIX = prefix, INDEX = index)) # If vertex is already selected except VertexAlreadySelected: # If first call if direction == History.NONE: raise VertexAlreadySelected # If unod or redo self.text.write( '{PREFIX}Vertex #{INDEX} selected'.format( PREFIX = prefix, INDEX = index))
def on_communication(self, states): # Local reference surface = self.surface # Prepare and send data data = [] for identifier, vertex in surface.selected(): vertex_position = vertex.localPosition data.append((index_of_vertex(vertex.name), vertex_position[0], vertex_position[1], vertex_position[2])) # Receive data and act based on it for vertex in surface.unlock_all(): vertex.color = COLOR_UNLOCKED try: received_data = self._connection.transfer(data) for i, x, y, z in received_data: vertex_name = name_of_vertex(i) surface[vertex_name].localPosition = x, y, z surface.lock(vertex_name).color = COLOR_LOCKED surface.update() # If 'NoneType|int' object is not iterable except TypeError: if received_data == COMM_RESTART: raise RestartApplication
def deselect_vertex(direction, prefix): index = index_of_vertex(vertex.name) try: surface.deselect(vertex.name) vertex.color = COLOR_GEOMETRY_DARK except VertexLocked: pass self.text.write( '{PREFIX}Vertex #{INDEX} deselected'.format( PREFIX=prefix, INDEX=index))
def deselect_vertex(direction, prefix): index = index_of_vertex(vertex.name) try: surface.deselect(vertex.name) vertex.color = COLOR_GEOMETRY_DARK except VertexLocked: pass self.text.write( '{PREFIX}Vertex #{INDEX} deselected'.format( PREFIX = prefix, INDEX = index))
def select_vertex(direction, prefix): index = index_of_vertex(vertex.name) # If the opponent user is not grabbing the vertex already try: surface.select(vertex.name) vertex.color = COLOR_GEOMETRY_LITE self.text.write( '{PREFIX}Vertex #{INDEX} selected'.format( PREFIX=prefix, INDEX=index)) # If the opponent user is grabbing the vertex except VertexLocked: self.text.write( '{PREFIX}Vertex #{INDEX} is locked'.format( PREFIX=prefix, INDEX=index)) # If vertex is already selected except VertexAlreadySelected: # If first call if direction == History.NONE: raise VertexAlreadySelected # If unod or redo self.text.write( '{PREFIX}Vertex #{INDEX} selected'.format( PREFIX=prefix, INDEX=index))