Mercurial > projects > doodle
view doodle/import/network.d @ 29:960b408d3ac5
Builds and runs ok with builder now.
Still heaps of cleaning up to do, especially code roughly
imported from dog.
author | Graham St Jack <graham.stjack@internode.on.net> |
---|---|
date | Mon, 03 Aug 2009 23:19:55 +0930 |
parents | 1754cb773d41 |
children |
line wrap: on
line source
module doodle.presentation.network; //import doodle.presentation.model; version(none) { enum EdgeEnd { Source, Target }; interface NetworkObserver { // Node changes void node_added(GraphNode node, GraphElement container); void node_changed(GraphNode node); void node_relocated(GraphNode node, GraphElement container); void node_removed(GraphNode node, GraphElement container); // Edge changes void edge_added(GraphEdge node, GraphConnector anchor1, GraphConnector anchor2); void edge_changed(GraphEdge edge); void edge_rerouted(); void edge_removed(); } interface Network { void add_observer(NetworkObserver observer); void remove_observer(NetworkObserver observer); // // Interrogation: // GraphNode[] get_root_nodes(); // Inquire whether in principle a node of node_type // can be added at the given point, possibly nested // within the nest node. The nest can be null. bool can_add(char[] node_type, Point point, // necessary? GraphNode nest); bool can_relocate(GraphNode node); bool can_remove(GraphNode node); // Inquire whether in principle the source element can // be connected to the target element using // an edge of edge_type. This might return true even // though the real operation would fail due to deeper checking. bool can_connect(char[] edge_type, GraphElement source_element, Point source_point, GraphElement target_element, Point target_point); // Inquire whether in principle a given end of an existing edge // can be rerouted from old_element to new_element at new_point. // old_element and new_element may be the same element. bool can_reroute(GraphEdge edge, EdgeEnd end, GraphElement old_element, GraphElement new_element, Point new_point); bool can_disconnect(GraphEdge edge); // // Manipulation: // // Attempt to really add a node... GraphNode add(char[] node_type, /* initial properties, */ Point point, GraphNode nest); void relocate(GraphNode node, GraphElement old_container, GraphElement new_container, Point new_point); // Attempt to really remove a node void remove(GraphNode node); // Attempt to really connect the source element to the target element // using an edge of the given type with the given initial properties. GraphEdge connect(char[] edge_type, /* initial properties, */ GraphElement source_element, Point source_point, GraphElement target_element, Point target_point); // Attempt to really reroute.. void reroute(GraphEdge edge, EdgeEnd end, GraphElement old_element, GraphElement new_element, Point new_point); // Attempt to really remove an edge... void disconnect(GraphEdge edge); } }