/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to viz/graphcell.py

  • Committer: Gary van der Merwe
  • Date: 2007-08-16 13:31:29 UTC
  • mto: (256.2.37 gtk)
  • mto: This revision was merged to the branch mainline in revision 289.
  • Revision ID: garyvdm@gmail.com-20070816133129-20qwx6mad0tf6am3
Use nice Bézier curves for viz

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
 
145
145
        # Draw lines into the cell
146
146
        for start, end, colour in self.in_lines:
147
 
            ctx.move_to(cell_area.x + box_size * start + box_size / 2,
148
 
                        bg_area.y - bg_area.height / 2)
149
 
 
150
 
            if start - end > 1:
151
 
                ctx.line_to(cell_area.x + box_size * start, bg_area.y)
152
 
                ctx.line_to(cell_area.x + box_size * end + box_size, bg_area.y)
153
 
            elif start - end < -1:
154
 
                ctx.line_to(cell_area.x + box_size * start + box_size,
155
 
                            bg_area.y)
156
 
                ctx.line_to(cell_area.x + box_size * end, bg_area.y)
157
 
 
158
 
            ctx.line_to(cell_area.x + box_size * end + box_size / 2,
159
 
                        bg_area.y + bg_area.height / 2)
160
 
 
161
 
            self.set_colour(ctx, colour, 0.0, 0.65)
162
 
            ctx.stroke()
 
147
            self.render_line (ctx, cell_area, box_size,
 
148
                         bg_area.y, bg_area.height,
 
149
                         start, end, colour)
163
150
 
164
151
        # Draw lines out of the cell
165
152
        for start, end, colour in self.out_lines:
166
 
            ctx.move_to(cell_area.x + box_size * start + box_size / 2,
167
 
                        bg_area.y + bg_area.height / 2)
168
 
 
169
 
            if start - end > 1:
170
 
                ctx.line_to(cell_area.x + box_size * start,
171
 
                            bg_area.y + bg_area.height)
172
 
                ctx.line_to(cell_area.x + box_size * end + box_size,
173
 
                            bg_area.y + bg_area.height)
174
 
            elif start - end < -1:
175
 
                ctx.line_to(cell_area.x + box_size * start + box_size,
176
 
                            bg_area.y + bg_area.height)
177
 
                ctx.line_to(cell_area.x + box_size * end,
178
 
                            bg_area.y + bg_area.height)
179
 
 
180
 
            ctx.line_to(cell_area.x + box_size * end + box_size / 2,
181
 
                        bg_area.y + bg_area.height / 2 + bg_area.height)
182
 
 
183
 
            self.set_colour(ctx, colour, 0.0, 0.65)
184
 
            ctx.stroke()
 
153
            self.render_line (ctx, cell_area, box_size,
 
154
                         bg_area.y + bg_area.height, bg_area.height,
 
155
                         start, end, colour)
185
156
 
186
157
        # Draw the revision node in the right column
187
158
        (column, colour) = self.node
194
165
 
195
166
        self.set_colour(ctx, colour, 0.5, 1.0)
196
167
        ctx.fill()
 
168
    
 
169
    def render_line (self, ctx, cell_area, box_size, mid, height, start, end, colour):
 
170
        startx = cell_area.x + box_size * start + box_size / 2
 
171
        endx = cell_area.x + box_size * end + box_size / 2
 
172
        
 
173
        ctx.move_to(startx, mid - height / 2)
 
174
        
 
175
        if start - end == 0 :
 
176
            ctx.line_to(endx, mid + height / 2)
 
177
        else:
 
178
            ctx.curve_to(startx, mid - height / 5,
 
179
                         startx, mid - height / 5,
 
180
                         startx + (endx - startx) / 2, mid)
 
181
            
 
182
            ctx.curve_to(endx, mid + height / 5,
 
183
                         endx, mid + height / 5 ,
 
184
                         endx, mid + height / 2)
 
185
            
 
186
        self.set_colour(ctx, colour, 0.0, 0.65)
 
187
        ctx.stroke()
 
188
        
 
 
b'\\ No newline at end of file'