~jeremysanders/veusz/trunk

« back to all changes in this revision

Viewing changes to veusz/widgets/axisbroken.py

  • Committer: Jeremy Sanders
  • Date: 2018-04-07 15:36:32 UTC
  • Revision ID: git-v1:1cfa32cb07e9143a5667edacab7930bffcf9985e
Fix github bug #244. Fix broken axis if the edge of the axis is not the edge of the plot.

Adds a test case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
200
200
            lowerupper = ( self.posstarts[self.rangeswitch],
201
201
                           self.posstops[self.rangeswitch] )
202
202
 
203
 
        axis.Axis.updateAxisLocation(self, bounds,
204
 
                                     otherposition=otherposition,
205
 
                                     lowerupperposition=lowerupper)
 
203
        axis.Axis.updateAxisLocation(
 
204
            self, bounds,
 
205
            otherposition=otherposition,
 
206
            lowerupperposition=lowerupper)
206
207
 
207
208
    def computePlottedRange(self):
208
209
        """Given range of data, recompute stops and start values of
260
261
        # temporarily change position of axis to other side for drawing
261
262
        self.updateAxisLocation(posn, otherposition=otheredge)
262
263
        if not s.Line.hide:
263
 
            self._drawAxisLine(painter)
 
264
            self._drawAxisLine(painter, posn)
264
265
 
265
266
        for i in crange(self.breakvnum):
266
267
            self.switchBreak(i, posn, otherposition=otheredge)
276
277
 
277
278
        self.switchBreak(None, posn)
278
279
 
279
 
    def _drawAxisLine(self, painter):
 
280
    def _drawAxisLine(self, painter, posn):
280
281
        """Draw the line of the axis, indicating broken positions.
281
282
        We currently use a triangle to mark the broken position
282
283
        """
300
301
        p2.append(0.)
301
302
 
302
303
        # scale points by length of axis and add correct origin
303
 
        scale = self.coordParr2 - self.coordParr1
304
 
        p1 = N.array(p1) * scale + self.coordParr1
305
 
        p2 = N.array(p2) * scale + self.coordPerp
306
 
 
307
 
        if self.settings.direction == 'vertical':
 
304
        s = self.settings
 
305
 
 
306
        if s.direction == 'vertical':
 
307
            delta = posn[1]-posn[3]
 
308
            minv = posn[3]
 
309
        else:
 
310
            delta = posn[2]-posn[0]
 
311
            minv = posn[0]
 
312
 
 
313
        p1 = N.array(p1)*delta + minv
 
314
        p2 = N.array(p2)*delta + self.coordPerp
 
315
 
 
316
        if s.direction == 'vertical':
308
317
            p1, p2 = p2, p1
309
318
 
310
319
        # convert to polygon and draw
311
320
        poly = qt4.QPolygonF()
312
321
        utils.addNumpyToPolygonF(poly, p1, p2)
313
322
 
314
 
        pen = self.settings.get('Line').makeQPen(painter)
 
323
        pen = s.get('Line').makeQPen(painter)
315
324
        pen.setCapStyle(qt4.Qt.FlatCap)
316
325
        painter.setPen(pen)
317
326
        painter.drawPolyline(poly)
372
381
 
373
382
        # plot the line along the axis
374
383
        if not s.Line.hide:
375
 
            self._drawAxisLine(painter)
 
384
            self._drawAxisLine(painter, posn)
376
385
 
377
386
        max_delta = 0
378
387
        for i in crange(self.breakvnum):