# -*- python -*-
#
# OpenAlea.GraphEditor: OpenAlea graphical user interface
#
# Copyright 2006-2009 INRIA - CIRAD - INRA
#
# File author(s): Daniel Barbeau <daniel.barbeau@sophia.inria.fr>
#
# Distributed under the Cecill-C License.
# See accompanying file LICENSE.txt or copy at
# http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html
#
# OpenAlea WebSite : http://openalea.gforge.inria.fr
#
###############################################################################
"""Interfaces for the generic graph view module. The graph view widget
won't check for inheritance of the object's it is passed. Instead, it
will check the interfaces match more or less."""
__license__ = "Cecill-C"
__revision__ = " $Id$ "
[docs]class IGraphViewStrategies(object):
"""Define implementations of this trait
class to define the behaviour of the graph.
For example : DataFlowGraphViewTrait, TreeGraphViewTrait,
NetworkGraphViewTrait..."""
__metaclass__ = IInterfaceMetaClass
[docs] def get_graph_model_type(cls):
"""Returns the classobj defining the graph type"""
raise NotImplementedError
[docs] def create_view(self, parent, graph, *args, **kwargs):
"""Instanciates the view"""
raise NotImplementedError
[docs] def get_connector_types(cls):
raise NotImplementedError
[docs] def initialise_graph_view(cls, graphView, graphModel):
"""intialise graph view from model"""
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphListener(object):
__metaclass__ = IInterfaceMetaClass
[docs] def vertex_added(self, vtype, vertexModel):
raise NotImplementedError
[docs] def edge_added(self, edgeModel, srcPort, dstPort):
raise NotImplementedError
[docs] def vertex_removed(self, vtype, vertexModel):
raise NotImplementedError
[docs] def edge_removed(self, edgeModel):
raise NotImplementedError
def _new_edge_start(self, srcPt, etype, source):
raise NotImplementedError
def _new_edge_set_destination(self, *dest):
raise NotImplementedError
def _new_edge_end(self):
raise NotImplementedError
[docs] def find_closest_connectable(self, *args, **kwargs):
raise NotImplementedError
[docs] def post_addition(self, *args, **kwargs):
raise NotImplementedError
[docs] def is_connectable(self, *args, **kwargs):
raise NotImplementedError
[docs] def clear(self, *args, **kwargs):
raise NotImplementedError
[docs] def initialise_from_model(self):
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphAdapter(object):
__metaclass__ = IInterfaceMetaClass
[docs] def add_vertex(self, *args, **kargs):
NotImplementedError
[docs] def get_vertex(self, *args, **kargs):
raise NotImplementedError
[docs] def remove_vertex(self, *args, **kargs):
raise NotImplementedError
[docs] def remove_vertices(self, *args, **kargs):
raise NotImplementedError
[docs] def get_vertex_outputs(self, *args, **kargs):
raise NotImplementedError
[docs] def get_vertex_output(self, *args, **kargs):
raise NotImplementedError
[docs] def add_edge(self, *args, **kargs):
raise NotImplementedError
[docs] def remove_edge(self, *args, **kargs):
raise NotImplementedError
[docs] def is_output(self, *args, **kargs):
raise NotImplementedError
[docs] def get_vertex_types(self):
raise NotImplementedError
[docs] def get_edge_types(self):
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewConnectable(object):
"""Interface for connectable objects"""
__metaclass__ = IInterfaceMetaClass
[docs] def set_highlighted(self, *args, **kwargs):
raise NotImplementedError
[docs] def get_scene_center(self):
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewElement(object):
"""Base class for elements in a GraphView"""
__metaclass__ = IInterfaceMetaClass
[docs] def position_changed(self, *args):
"""Place the element's representation in
the view space"""
raise NotImplementedError
[docs] def add_to_view(self, view):
"""add this element to the graphical view"""
raise NotImplementedError
[docs] def remove_from_view(self, view):
"""remove this element from the graphical view"""
raise NotImplementedError
[docs] def notify(self, sender, event):
"""called by the observed objects
Expected event = (\"metadata_changed\", "position", [x,x], list)
"""
raise NotImplementedError
[docs] def store_view_data(self, **kwargs):
raise NotImplementedError
[docs] def get_view_data(self, key):
raise NotImplementedError
[docs] def initialise_from_model(self):
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewVertex (IGraphViewElement):
[docs] def lock_position(self, val=True):
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewAnnotation(IGraphViewElement):
"""Interface for Annotations"""
[docs] def set_text(self, text):
"""to change the visible text"""
raise NotImplementedError
[docs] def notify(self, sender, event):
"""(\"metadata_changed\", \"text\", \"a string\", str)"""
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewEdge(IGraphViewElement):
"""Interface for edges between two vertexs."""
[docs] def update_line_source(self, *pos):
"""updates this edge's starting point. Called when
source point is moved"""
raise NotImplementedError
[docs] def update_line_destination(self, *pos):
"""updates this edge's ending point. Called when
dest point is moved"""
raise NotImplementedError
[docs] def notify(self, sender, event):
"""(\"metadata_changed\", \"canvasPosition\", [x,x], list)"""
raise NotImplementedError
#------*************************************************------#
[docs]class IGraphViewFloatingEdge(object):
"""Interface for edges to be drawn during
creation time, ie while the user drags."""
__metaclass__ = IInterfaceMetaClass
def __init__(self, src):
raise NotImplementedError
[docs] def consolidate(self, model):
"""returns whatever object is under the mouse
pointer at the time the button was released"""
raise NotImplementedError
[docs] def get_connections(self, *args):
raise NotImplementedError