Mercurial > projects > doodle
annotate 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 |
rev | line source |
---|---|
29
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
1 module doodle.presentation.network; |
0 | 2 |
29
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
3 //import doodle.presentation.model; |
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
4 |
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
5 version(none) { |
0 | 6 |
7 enum EdgeEnd { | |
8 Source, | |
9 Target | |
10 }; | |
11 | |
12 interface NetworkObserver { | |
13 // Node changes | |
14 | |
15 void node_added(GraphNode node, | |
16 GraphElement container); | |
17 void node_changed(GraphNode node); | |
18 void node_relocated(GraphNode node, | |
19 GraphElement container); | |
20 void node_removed(GraphNode node, | |
21 GraphElement container); | |
22 | |
23 // Edge changes | |
24 | |
25 void edge_added(GraphEdge node, | |
26 GraphConnector anchor1, GraphConnector anchor2); | |
27 void edge_changed(GraphEdge edge); | |
28 void edge_rerouted(); | |
29 void edge_removed(); | |
30 } | |
31 | |
32 interface Network { | |
33 void add_observer(NetworkObserver observer); | |
34 void remove_observer(NetworkObserver observer); | |
35 | |
36 // | |
37 // Interrogation: | |
38 // | |
39 | |
40 GraphNode[] get_root_nodes(); | |
41 | |
42 // Inquire whether in principle a node of node_type | |
43 // can be added at the given point, possibly nested | |
44 // within the nest node. The nest can be null. | |
45 bool can_add(char[] node_type, | |
46 Point point, // necessary? | |
47 GraphNode nest); | |
48 | |
49 bool can_relocate(GraphNode node); | |
50 | |
51 bool can_remove(GraphNode node); | |
52 | |
53 // Inquire whether in principle the source element can | |
54 // be connected to the target element using | |
55 // an edge of edge_type. This might return true even | |
56 // though the real operation would fail due to deeper checking. | |
57 bool can_connect(char[] edge_type, | |
58 GraphElement source_element, Point source_point, | |
59 GraphElement target_element, Point target_point); | |
60 | |
61 // Inquire whether in principle a given end of an existing edge | |
62 // can be rerouted from old_element to new_element at new_point. | |
63 // old_element and new_element may be the same element. | |
64 bool can_reroute(GraphEdge edge, EdgeEnd end, | |
65 GraphElement old_element, | |
66 GraphElement new_element, Point new_point); | |
67 | |
68 bool can_disconnect(GraphEdge edge); | |
69 | |
70 // | |
71 // Manipulation: | |
72 // | |
73 | |
74 // Attempt to really add a node... | |
75 GraphNode add(char[] node_type, /* initial properties, */ | |
76 Point point, | |
77 GraphNode nest); | |
78 | |
79 void relocate(GraphNode node, | |
80 GraphElement old_container, | |
81 GraphElement new_container, Point new_point); | |
82 | |
83 // Attempt to really remove a node | |
84 void remove(GraphNode node); | |
85 | |
86 // Attempt to really connect the source element to the target element | |
87 // using an edge of the given type with the given initial properties. | |
88 GraphEdge connect(char[] edge_type, /* initial properties, */ | |
89 GraphElement source_element, Point source_point, | |
90 GraphElement target_element, Point target_point); | |
91 | |
92 // Attempt to really reroute.. | |
93 void reroute(GraphEdge edge, EdgeEnd end, | |
94 GraphElement old_element, | |
95 GraphElement new_element, Point new_point); | |
96 | |
97 // Attempt to really remove an edge... | |
98 void disconnect(GraphEdge edge); | |
99 } | |
29
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
100 |
960b408d3ac5
Builds and runs ok with builder now.
Graham St Jack <graham.stjack@internode.on.net>
parents:
28
diff
changeset
|
101 } |