From 0a2d87148073cd5d8a8e9cb1f3d132062a2b7a7b Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Tue, 20 Feb 2007 03:49:50 +0000 Subject: [PATCH] * src/plugins/DescendChart.py: include blank pages option * src/plugins/AncestorChart2.py: include blank pages option svn: r8184 --- ChangeLog | 4 ++++ src/plugins/AncestorChart2.py | 32 +++++++++++++++++++++++++------- src/plugins/DescendChart.py | 21 ++++++++++++++++++++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b37268fef..b679ab2e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-02-19 Brian Matherly + * src/plugins/DescendChart.py: include blank pages option + * src/plugins/AncestorChart2.py: include blank pages option + 2007-02-19 Don Allingham * src/Editors/_EditPlace.py: note list support * src/Editors/_EditAddress.py: note list support diff --git a/src/plugins/AncestorChart2.py b/src/plugins/AncestorChart2.py index c612c8688..b64809da2 100644 --- a/src/plugins/AncestorChart2.py +++ b/src/plugins/AncestorChart2.py @@ -111,11 +111,8 @@ class GenChart: return (x,y) def get(self,index): - try: - (x,y) = self.index_to_xy(index) - return self.array[y][x] - except: - return None + (x,y) = self.index_to_xy(index) + return self.get_xy(x,y) def get_xy(self,x,y): value = 0 @@ -130,7 +127,7 @@ class GenChart: self.array[y][x] = value def dimensions(self): - return (max(self.array.keys()),self.max_x+1) + return (max(self.array.keys())+1,self.max_x+1) def compress(self): new_map = {} @@ -183,6 +180,7 @@ class AncestorChart(Report): pagebbg - Whether to include page breaks between generations. dispf - Display format for the output box. singlep - Whether to scale to fit on a single page. + indblank - Whether to include blank pages. compress - Whether to compress chart. """ Report.__init__(self,database,person,options_class) @@ -191,6 +189,7 @@ class AncestorChart(Report): = options_class.get_report_generations() self.display = options_class.handler.options_dict['dispf'] self.force_fit = options_class.handler.options_dict['singlep'] + self.incblank = options_class.handler.options_dict['incblank'] self.compress = options_class.handler.options_dict['compress'] name = NameDisplay.displayer.display_formal(person) @@ -348,6 +347,16 @@ class AncestorChart(Report): self.doc.add_draw_style("AC2-line",g) def print_page(self,startx,stopx,starty,stopy,colx,coly): + + if not self.incblank: + blank = True + for y in range(starty,stopy): + for x in range(startx,stopx): + if self.genchart.get_xy(x,y) != 0: + blank = False + break + if not blank: break + if blank: return self.doc.start_page() if self.title and self.force_fit: @@ -415,7 +424,7 @@ class AncestorChart(Report): self.genchart.set_xy(px-1,py,3) for ty in range(y+1,py): self.genchart.set_xy(x,ty,2) - + #------------------------------------------------------------------------ # # @@ -434,12 +443,16 @@ class AncestorChartOptions(ReportOptions): # Options specific for this report self.options_dict = { 'singlep' : 1, + 'incblank' : 1, 'compress' : 1, } self.options_help = { 'singlep' : ("=0/1","Whether to scale to fit on a single page.", ["Do not scale to fit","Scale to fit"], True), + 'incblank' : ("=0/1","Whether to include pages that are blank.", + ["Do not include blank pages","Include blank pages"], + True), 'compress' : ("=0/1","Whether to compress chart.", ["Do not compress chart","Compress chart"], True), @@ -469,6 +482,10 @@ class AncestorChartOptions(ReportOptions): self.scale.set_active(self.options_dict['singlep']) dialog.add_option('',self.scale) + self.blank = gtk.CheckButton(_('Include Blank Pages')) + self.blank.set_active(self.options_dict['incblank']) + dialog.add_option('',self.blank) + self.compress = gtk.CheckButton(_('Co_mpress chart')) self.compress.set_active(self.options_dict['compress']) dialog.add_option('',self.compress) @@ -478,6 +495,7 @@ class AncestorChartOptions(ReportOptions): Parses the custom options that we have added. """ self.options_dict['singlep'] = int(self.scale.get_active ()) + self.options_dict['incblank'] = int(self.blank.get_active()) self.options_dict['compress'] = int(self.compress.get_active ()) def make_default_style(self,default_style): diff --git a/src/plugins/DescendChart.py b/src/plugins/DescendChart.py index e951f22cd..29b900024 100644 --- a/src/plugins/DescendChart.py +++ b/src/plugins/DescendChart.py @@ -130,6 +130,7 @@ class DescendChart(Report): = options_class.get_report_generations() self.display = options_class.handler.options_dict['dispf'] self.force_fit = options_class.handler.options_dict['singlep'] + self.incblank = options_class.handler.options_dict['incblank'] self.max_gen = options_class.handler.options_dict['maxgen'] name = NameDisplay.displayer.display_formal(person) @@ -325,6 +326,16 @@ class DescendChart(Report): def print_page(self,startx,stopx,starty,stopy,colx,coly): + if not self.incblank: + blank = True + for y in range(starty,stopy): + for x in range(startx,stopx): + if self.genchart.get_xy(x,y) != 0: + blank = False + break + if not blank: break + if blank: return + self.doc.start_page() if self.title and self.force_fit: self.doc.center_text('DC2-title',self.title,self.doc.get_usable_width()/2,0) @@ -357,7 +368,6 @@ class DescendChart(Report): xnext = (phys_x+1)*self.delta self.doc.draw_line('DC2-line', xlast, ystart, xlast, ystop) self.doc.draw_line('DC2-line', xlast, ystop, xnext, ystop) - if x%2: phys_x +=1 @@ -389,11 +399,15 @@ class DescendChartOptions(ReportOptions): self.options_dict = { 'singlep' : 1, 'maxgen' : 32, + 'incblank' : 1, } self.options_help = { 'singlep' : ("=0/1","Whether to scale to fit on a single page.", ["Do not scale to fit","Scale to fit"], True), + 'incblank' : ("=0/1","Whether to include pages that are blank.", + ["Do not include blank pages","Include blank pages"], + True), } def enable_options(self): @@ -417,6 +431,10 @@ class DescendChartOptions(ReportOptions): self.scale = gtk.CheckButton(_('Sc_ale to fit on a single page')) self.scale.set_active(self.options_dict['singlep']) dialog.add_option('',self.scale) + + self.blank = gtk.CheckButton(_('Include Blank Pages')) + self.blank.set_active(self.options_dict['incblank']) + dialog.add_option('',self.blank) self.max_gen = gtk.SpinButton(gtk.Adjustment(1,1,100,1)) self.max_gen.set_value(self.options_dict['maxgen']) @@ -428,6 +446,7 @@ class DescendChartOptions(ReportOptions): Parses the custom options that we have added. """ self.options_dict['singlep'] = int(self.scale.get_active ()) + self.options_dict['incblank'] = int(self.blank.get_active()) self.options_dict['maxgen'] = int(self.max_gen.get_value_as_int()) def make_default_style(self,default_style):