Mercurial > projects > doodle
annotate doodle/fig/diagram_elements.d @ 58:c63719604adb
Beginnings of creating a rectangle...
author | "David Bryant <bagnose@gmail.com>" |
---|---|
date | Mon, 09 Aug 2010 21:43:24 +0930 |
parents | 30ecedfe2ce2 |
children | 43cc2135ced0 |
rev | line source |
---|---|
54 | 1 module doodle.fig.diagram_elements; |
27 | 2 |
44 | 3 private { |
4 import doodle.tk.geometry; | |
54 | 5 import doodle.cairo.routines; |
44 | 6 } |
7 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
8 interface IDiagram { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
9 void add(DiagramElement element); |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
10 } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
11 |
54 | 12 abstract class DiagramElement { |
44 | 13 Rectangle bounds() const; |
14 | |
15 void draw(in Rectangle damage, scope Context cr) const; | |
16 | |
17 private { | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
18 //GraphElement _container; // FIXME use an interface to the container |
54 | 19 } |
20 } | |
21 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
22 /* |
54 | 23 abstract class SemanticModelBridge { |
24 }; | |
25 | |
26 abstract class GraphElement : DiagramElement { | |
27 // Link to model via bridge goes here | |
28 private { | |
29 SemanticModelBridge _modelBridge; | |
30 GraphConnector[] _anchorages; | |
44 | 31 } |
32 } | |
27 | 33 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
34 class GraphConnector { |
44 | 35 } |
27 | 36 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
37 class GraphNode : GraphElement { |
44 | 38 } |
27 | 39 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
40 class GraphEdge : GraphElement { |
44 | 41 private { |
54 | 42 GraphConnector[2] _anchors; |
44 | 43 } |
44 } | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
45 */ |
44 | 46 |
54 | 47 abstract class LeafElement : DiagramElement { |
48 } | |
49 | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
50 /* |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
51 class TextElement : LeafElement { |
54 | 52 } |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
53 */ |
54 | 54 |
55 abstract class GraphicPrimitive : LeafElement { | |
44 | 56 } |
54 | 57 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
58 /* |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
59 class PolylinePrimitive : GraphicPrimitive { |
54 | 60 private { |
61 Point[] _waypoints; | |
62 } | |
63 } | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
64 */ |
54 | 65 |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
66 class RectanglePrimitive : GraphicPrimitive { |
54 | 67 override void draw(in Rectangle damage, scope Context cr) const { |
68 rectangle(cr, bounds); | |
69 } | |
58
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
70 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
71 override Rectangle bounds() const { return _bounds; } |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
72 |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
73 private { |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
74 Rectangle _bounds; |
c63719604adb
Beginnings of creating a rectangle...
"David Bryant <bagnose@gmail.com>"
parents:
54
diff
changeset
|
75 } |
54 | 76 } |