fanchart feature: single color background + filter improvement: bold text
svn: r20351
This commit is contained in:
parent
ca4127b003
commit
4cc2af5eb6
@ -85,9 +85,9 @@ def gender_code(is_male):
|
|||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
PIXELS_PER_GENERATION = 50 # size of radius for generation
|
PIXELS_PER_GENERATION = 50 # size of radius for generation
|
||||||
BORDER_EDGE_WIDTH = 10
|
BORDER_EDGE_WIDTH = 10 # empty white box size at edge to indicate parents
|
||||||
CHILDRING_WIDTH = 12
|
CHILDRING_WIDTH = 12 # width of the children ring inside the person
|
||||||
TRANSLATE_PX = 10
|
TRANSLATE_PX = 10 # size of the central circle, used to move the chart
|
||||||
|
|
||||||
BACKGROUND_SCHEME1 = 0
|
BACKGROUND_SCHEME1 = 0
|
||||||
BACKGROUND_SCHEME2 = 1
|
BACKGROUND_SCHEME2 = 1
|
||||||
@ -439,7 +439,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
cr.save()
|
cr.save()
|
||||||
name = name_displayer.display(person)
|
name = name_displayer.display(person)
|
||||||
self.draw_text(cr, name, self.center - 10, 95, 455, False,
|
self.draw_text(cr, name, self.center - 10, 95, 455, False,
|
||||||
self.fontcolor(r,g,b))
|
self.fontcolor(r, g, b), self.fontbold(a))
|
||||||
cr.restore()
|
cr.restore()
|
||||||
#draw center to move chart
|
#draw center to move chart
|
||||||
cr.set_source_rgb(0, 0, 0) # black
|
cr.set_source_rgb(0, 0, 0) # black
|
||||||
@ -523,7 +523,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
radial = True
|
radial = True
|
||||||
radstart = radius - PIXELS_PER_GENERATION + 4
|
radstart = radius - PIXELS_PER_GENERATION + 4
|
||||||
self.draw_text(cr, name, radstart, start, stop, radial,
|
self.draw_text(cr, name, radstart, start, stop, radial,
|
||||||
self.fontcolor(r, g, b))
|
self.fontcolor(r, g, b), self.fontbold(a))
|
||||||
cr.restore()
|
cr.restore()
|
||||||
|
|
||||||
def drawchildring(self, cr):
|
def drawchildring(self, cr):
|
||||||
@ -576,7 +576,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
cr.fill()
|
cr.fill()
|
||||||
|
|
||||||
def draw_text(self, cr, text, radius, start, stop, radial=False,
|
def draw_text(self, cr, text, radius, start, stop, radial=False,
|
||||||
fontcolor=(0, 0, 0)):
|
fontcolor=(0, 0, 0), bold=False):
|
||||||
"""
|
"""
|
||||||
Display text at a particular radius, between start and stop
|
Display text at a particular radius, between start and stop
|
||||||
degrees.
|
degrees.
|
||||||
@ -585,6 +585,8 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
font = Pango.FontDescription(self.fontdescr)
|
font = Pango.FontDescription(self.fontdescr)
|
||||||
fontsize = self.fontsize
|
fontsize = self.fontsize
|
||||||
font.set_size(fontsize * Pango.SCALE)
|
font.set_size(fontsize * Pango.SCALE)
|
||||||
|
if bold:
|
||||||
|
font.set_weight(Pango.Weight.BOLD)
|
||||||
cr.set_source_rgb(fontcolor[0], fontcolor[1], fontcolor[2])
|
cr.set_source_rgb(fontcolor[0], fontcolor[1], fontcolor[2])
|
||||||
if radial and self.radialtext:
|
if radial and self.radialtext:
|
||||||
cr.save()
|
cr.save()
|
||||||
@ -739,9 +741,10 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
cstart[2]/255)
|
cstart[2]/255)
|
||||||
cend_hsv = colorsys.rgb_to_hsv(cend[0]/255, cend[1]/255,
|
cend_hsv = colorsys.rgb_to_hsv(cend[0]/255, cend[1]/255,
|
||||||
cend[2]/255)
|
cend[2]/255)
|
||||||
if self.background == BACKGROUND_GENDER:
|
if self.background in [BACKGROUND_GENDER, BACKGROUND_SINGLE_COLOR]:
|
||||||
# nothing to precompute
|
# nothing to precompute
|
||||||
self.colors = None
|
self.colors = None
|
||||||
|
self.maincolor = cstart
|
||||||
elif self.background == BACKGROUND_GRAD_GEN:
|
elif self.background == BACKGROUND_GRAD_GEN:
|
||||||
#compute the colors, -1, 0, ..., maxgen
|
#compute the colors, -1, 0, ..., maxgen
|
||||||
divs = [x/(maxgen-1) for x in range(maxgen)]
|
divs = [x/(maxgen-1) for x in range(maxgen)]
|
||||||
@ -827,6 +830,8 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
alive = False
|
alive = False
|
||||||
backgr, border = gui.utils.color_graph_box(alive, person.gender)
|
backgr, border = gui.utils.color_graph_box(alive, person.gender)
|
||||||
color = gui.utils.hex_to_rgb(backgr)
|
color = gui.utils.hex_to_rgb(backgr)
|
||||||
|
elif self.background == BACKGROUND_SINGLE_COLOR:
|
||||||
|
color = self.maincolor
|
||||||
elif self.background == BACKGROUND_GRAD_AGE:
|
elif self.background == BACKGROUND_GRAD_AGE:
|
||||||
color = userdata[0]
|
color = userdata[0]
|
||||||
else:
|
else:
|
||||||
@ -837,7 +842,10 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
color = [x*.9 for x in color]
|
color = [x*.9 for x in color]
|
||||||
# now we set transparency data
|
# now we set transparency data
|
||||||
if self.filter and not self.filter.match(person.handle, self.dbstate.db):
|
if self.filter and not self.filter.match(person.handle, self.dbstate.db):
|
||||||
alpha = self.alpha_filter
|
if self.background == BACKGROUND_SINGLE_COLOR:
|
||||||
|
alpha = 0. # no color shown
|
||||||
|
else:
|
||||||
|
alpha = self.alpha_filter
|
||||||
else:
|
else:
|
||||||
alpha = 1.
|
alpha = 1.
|
||||||
|
|
||||||
@ -858,6 +866,15 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
self.cache_fontcolor[(r, g, b)] = (255, 255, 255)
|
self.cache_fontcolor[(r, g, b)] = (255, 255, 255)
|
||||||
return self.cache_fontcolor[(r, g, b)]
|
return self.cache_fontcolor[(r, g, b)]
|
||||||
|
|
||||||
|
def fontbold(self, a):
|
||||||
|
"""
|
||||||
|
The font should be bold if no transparency and font is set.
|
||||||
|
In that case, True is returned
|
||||||
|
"""
|
||||||
|
if a >= 1. and self.filter:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def expand_parents(self, generation, selected, current):
|
def expand_parents(self, generation, selected, current):
|
||||||
if generation >= self.generations: return
|
if generation >= self.generations: return
|
||||||
selected = 2 * selected
|
selected = 2 * selected
|
||||||
@ -941,7 +958,7 @@ class FanChartWidget(Gtk.DrawingArea):
|
|||||||
self.angle[generation][selected-1] = [start,start,male,
|
self.angle[generation][selected-1] = [start,start,male,
|
||||||
COLLAPSED]
|
COLLAPSED]
|
||||||
self.hide_parents(generation+1, selected-1, start)
|
self.hide_parents(generation+1, selected-1, start)
|
||||||
elif gstate == self.EXPANDED: # let's shrink
|
elif gstate == EXPANDED: # let's shrink
|
||||||
if gmale:
|
if gmale:
|
||||||
# shrink from right
|
# shrink from right
|
||||||
slice = (gstop - gstart)/2.0
|
slice = (gstop - gstart)/2.0
|
||||||
|
@ -274,6 +274,8 @@ class FanChartView(fanchart.FanChartGrampsGUI, NavigationView):
|
|||||||
(fanchart.BACKGROUND_GENDER, _('Gender colors')),
|
(fanchart.BACKGROUND_GENDER, _('Gender colors')),
|
||||||
(fanchart.BACKGROUND_GRAD_GEN, _('Generation based gradient')),
|
(fanchart.BACKGROUND_GRAD_GEN, _('Generation based gradient')),
|
||||||
(fanchart.BACKGROUND_GRAD_AGE, _('Age (0-100) based gradient')),
|
(fanchart.BACKGROUND_GRAD_AGE, _('Age (0-100) based gradient')),
|
||||||
|
(fanchart.BACKGROUND_SINGLE_COLOR,
|
||||||
|
_('Single main (filter) color')),
|
||||||
(fanchart.BACKGROUND_WHITE, _('White')),
|
(fanchart.BACKGROUND_WHITE, _('White')),
|
||||||
(fanchart.BACKGROUND_SCHEME1, _('Color scheme classic report')),
|
(fanchart.BACKGROUND_SCHEME1, _('Color scheme classic report')),
|
||||||
(fanchart.BACKGROUND_SCHEME2, _('Color scheme classic view')),
|
(fanchart.BACKGROUND_SCHEME2, _('Color scheme classic view')),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user