import traceback
from optimeed.core.tools import str_all_attr, rgetattr
from optimeed.visualize.gui.gui_mainWindow import gui_mainWindow
from optimeed.visualize.gui.widgets.widget_graphs_visual import on_graph_click_interface
from optimeed.visualize.gui.widgets.widget_line_drawer import widget_line_drawer
from optimeed.visualize.gui.widgets.widget_openGL import widget_openGL
from optimeed.visualize.gui.widgets.widget_text import scrollable_widget_text
from optimeed.visualize.gui.widgets.widget_image import Widget_image
from optimeed.core.tools import str_all_attr, rgetattr
import traceback
[docs]class on_graph_click_showInfo(on_graph_click_interface):
"""On click: show informations about the points (loop through attributes)"""
def __init__(self, theLinkDataGraph, visuals=None):
"""
:param theLinkDataGraph: :class:`~optimeed.visualize.high_level.LinkDataGraph.LinkDataGraph`
visuals: A list of objects which have a get_widget(theDevice) method (Repr_opengl and Repr_lines are good examples)
"""
self.theLinkDataGraph = theLinkDataGraph
self.dataInformationVisuals = self.DataInformationVisuals()
if visuals is None:
self.visuals = [Repr_brut_attributes()]
else:
self.visuals = visuals
[docs] def graph_clicked(self, theGraphVisual, index_graph, index_trace, indices_points):
"""Action to perform when a point in the graph has been clicked:
Creates new window displaying the device and its informations
"""
try:
def actionOnWindowClosed(theVisual, _):
"""Action to perform when a window has been closed:
Remove the window from the dataInformationVisuals
"""
theVisual.close()
self.dataInformationVisuals.delete_visual(theVisual)
theTrace = theGraphVisual.get_graph(index_graph).get_trace(index_trace)
for index_point in indices_points:
theDevice = self.theLinkDataGraph.get_dataObject_from_graph(index_graph, index_trace, index_point)
theWidgetList = list()
for visual in self.visuals:
theWidgetList.append(visual.get_widget(theDevice))
visual_temp = gui_mainWindow(theWidgetList, actionOnWindowClosed=actionOnWindowClosed)
self.dataInformationVisuals.add_visual(visual_temp, theTrace, index_point)
visual_temp.run(False)
except KeyboardInterrupt:
raise
except Exception:
print("Following error occurred in visualisation :" + traceback.format_exc())
[docs] def get_name(self):
return "Show informations"
[docs]class Repr_brut_attributes:
def __init__(self, is_light=True, convertToHtml=True, recursion_level=5):
self.is_light = is_light
self.convertToHtml = convertToHtml
self.recursion_level = recursion_level
[docs]class Repr_lines:
def __init__(self, attribute_lines):
self.attribute_lines = attribute_lines
[docs]class Repr_opengl:
def __init__(self, DeviceDrawer):
self.DeviceDrawer = DeviceDrawer
[docs]class Repr_image:
def __init__(self, get_base_64_from_device):
"""
Display an image (png) representation of the motor
:param get_base_64_from_device: method taking a device as input and returns a base64 string
"""
self.get_base_64_from_device = get_base_64_from_device