Graph view shows graph
This commit is contained in:
@@ -9,13 +9,13 @@ from PySide6.QtWidgets import QAbstractItemView, QDialog, QHeaderView, QMenu
|
||||
from bedit_core.models import Component, ComponentID, EquationImplementation, GraphImplementation, Port, PortID, Parameter, ParameterID
|
||||
from bedit_core.models import Document as CoreDocument
|
||||
from bedit_gui.documents import Document
|
||||
from bedit_gui.models import Icon
|
||||
from bedit_gui.models import Graph, Icon
|
||||
from bedit_gui.views.dialogs.interface_editor_dialog import InterfaceEditorDialog
|
||||
from bedit_gui.views.dialogs.param_editor_dialog import ParamEditorDialog
|
||||
from bedit_gui.views.icon_editor_window import IconEditorWindow
|
||||
from bedit_gui.views.main_window import MainWindow
|
||||
from bedit_gui.views.models.document_tree_model import DocumentTreeModel
|
||||
from bedit_gui.utils.icon import render_icon
|
||||
from bedit_gui.utils.icon import render_fitted_icon
|
||||
|
||||
ICON_SIZE = QSize(32, 32)
|
||||
|
||||
@@ -102,7 +102,7 @@ class DocumentTreeController(QObject):
|
||||
self._collect_components(model.root)
|
||||
for component_id, component in self._components.items():
|
||||
icon = self.document.component_icon(component_id)
|
||||
self.model.set_component_icon(component_id, render_icon(icon, component.interface.ports, ICON_SIZE))
|
||||
self.model.set_component_icon(component_id, render_fitted_icon(icon, component.interface.ports, ICON_SIZE))
|
||||
|
||||
# Optional presentation behavior. Later, you could instead remember
|
||||
# expanded component IDs and restore only those nodes.
|
||||
@@ -121,7 +121,9 @@ class DocumentTreeController(QObject):
|
||||
self.window.equation_editor.set_component(None)
|
||||
self.window.equation_editor.hide()
|
||||
if component is not None and isinstance(component.implementation, GraphImplementation):
|
||||
self.window.graph_editor.set_component(component)
|
||||
graph = self.document.graph_database().graphs.get(self.document.component_id(component), Graph())
|
||||
icons = {component_id: self.document.component_icon(component_id) for component_id in component.implementation.graph.components}
|
||||
self.window.graph_editor.set_component(component, graph, icons)
|
||||
self.window.graph_editor.show()
|
||||
else:
|
||||
self.window.graph_editor.set_component(None)
|
||||
@@ -135,7 +137,10 @@ class DocumentTreeController(QObject):
|
||||
component = self._components.get(component_id)
|
||||
if component is None:
|
||||
return
|
||||
self.model.set_component_icon(component_id, render_icon(icon if isinstance(icon, Icon) else Icon(), component.interface.ports, ICON_SIZE))
|
||||
self.model.set_component_icon(component_id, render_fitted_icon(icon if isinstance(icon, Icon) else Icon(), component.interface.ports, ICON_SIZE))
|
||||
graph_component = self.window.graph_editor.component()
|
||||
if graph_component is not None and isinstance(graph_component.implementation, GraphImplementation) and component_id in graph_component.implementation.graph.components:
|
||||
self._show_component(graph_component)
|
||||
|
||||
def _collect_components(self, components: dict[ComponentID, Component]) -> None:
|
||||
for component_id, component in components.items():
|
||||
|
||||
Reference in New Issue
Block a user