Skip to content

Commit

Permalink
ENH: Show missing datasets with triangles
Browse files Browse the repository at this point in the history
  • Loading branch information
pastewka committed Oct 26, 2020
1 parent 145ef72 commit 4989a2c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dtool_lookup_gui/GraphWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
# SOFTWARE.
#

from math import pi
from math import pi, sqrt
_sqrt3 = sqrt(3)

import numpy as np

Expand All @@ -40,6 +41,13 @@ def square(context, x, y):
context.rectangle(x - 0.4, y - 0.4, 0.8, 0.8)


def triangle(context, x, y):
height = 0.5*_sqrt3
context.move_to(x, y - 0.5*height)
context.line_to(x + 0.5, y + 0.5*height)
context.line_to(x - 0.5, y + 0.5*height)
context.close_path()

class GraphWidget(Gtk.DrawingArea):
def __init__(self, builder, graph):
super().__init__()
Expand Down Expand Up @@ -102,12 +110,16 @@ def on_draw(self, area, context):
state = self.graph.get_vertex_properties('state')

# Draw vertices
root_color = Gdk.color_parse('red')
root_color = Gdk.color_parse('lightgreen')
does_not_exist_color = Gdk.color_parse('red')
dependency_color = Gdk.color_parse('lightblue')
for i, ((x, y), k, s) in enumerate(zip(positions, kind, state)):
if k == 'root':
context.set_source_rgb(*root_color.to_floats())
square(context, x, y)
elif k == 'does-not-exist':
context.set_source_rgb(*does_not_exist_color.to_floats())
triangle(context, x, y)
else:
context.set_source_rgb(*dependency_color.to_floats())
circle(context, x, y)
Expand Down

0 comments on commit 4989a2c

Please sign in to comment.