1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
"""
TrivalentGraph_Graphics.py
$Id$
"""
from pyglet.gl import *
from demoapp.graphics.colors import red, black, green, yellow
from demoapp.graphics.drawing import drawcircle2d, drawline2d
from demoapp.geometry.vectors import get_pos
from demoapp.foundation.tool_graphics import HighlightGraphics
# ==
NODE_RADIUS = 5
def draw_Node(pos, radius, numedges = 0, highlight_color = None, color = None):
if color is None:
if numedges < 3:
color = green
elif numedges == 3:
color = black
else:
color = red
x, y = pos
glColor3f(*color)
drawcircle2d(radius, x, y)
if highlight_color:
glColor3f(*highlight_color)
drawcircle2d(radius + 1, x, y)
drawcircle2d(radius + 2, x, y)
return
class TrivalentGraph_HighlightGraphics( HighlightGraphics):
def rubber_edge(self, node_or_pos_1, node_or_pos_2):
drawline2d( self.rubber_object_color,
get_pos(node_or_pos_1),
get_pos(node_or_pos_2) ) # draw_Edge = drawline2d?
def rubber_node(self, pos):
draw_Node(pos, NODE_RADIUS, color = self.rubber_object_color)
pass
def highlight_refusal(self, obj):
obj.draw( highlight_color = red) # bug: only implemented for nodes
pass
def highlight_connect_to(self, node):
node.draw( highlight_color = yellow)
pass
def highlight_merge(self, node1, node2):
node1.draw( highlight_color = yellow)
node2.draw( highlight_color = yellow)
pass
def highlight_insert_into(self, edge):
#todo
pass
def highlight_drag(self, node):
node.draw( highlight_color = yellow)
pass
def highlight_delete(self, obj):
pos = obj.pos
draw_Node(pos, NODE_RADIUS, color = red)
draw_Node(pos, NODE_RADIUS + 1, color = red)
pass
pass
# move all imports of the above
|