~ubuntu-branches/ubuntu/trusty/picviz/trusty

« back to all changes in this revision

Viewing changes to src/frontend/PicvizGui/lines.py

  • Committer: Bazaar Package Importer
  • Author(s): Pierre Chifflier
  • Date: 2009-03-30 10:42:08 UTC
  • Revision ID: james.westby@ubuntu.com-20090330104208-j095obwkp574t1lm
Tags: upstream-0.5
ImportĀ upstreamĀ versionĀ 0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from PyQt4 import QtCore, QtGui
 
2
 
 
3
import defaults
 
4
 
 
5
class Line:
 
6
        def __init__(self, scene, image):
 
7
                self.scene = scene
 
8
                self.image = image
 
9
 
 
10
        def QTColorGet(self, color):
 
11
                if (color == "#000000"):
 
12
                        return QtCore.Qt.black
 
13
                if (color == "#FF0000"):
 
14
                        return QtCore.Qt.red
 
15
                if (color == "#0000FF"):
 
16
                        return QtCore.Qt.blue
 
17
                if (color == "#FF9900"):
 
18
                        return QtCore.Qt.yellow
 
19
 
 
20
                return QtCore.Qt.black
 
21
 
 
22
        def addLines(self, show_max, axislimits=None):
 
23
                pen = QtGui.QPen()
 
24
 
 
25
                #print str(axislimits)
 
26
                linecounter = 0
 
27
                for line in self.image['lines']:
 
28
                        if linecounter == show_max:
 
29
                                return
 
30
                        linecounter = linecounter + 1
 
31
 
 
32
                        plotnb = 0 # Where we are in the axis
 
33
                        for plot in line:
 
34
                                if not line[plotnb]['hidden']:
 
35
                                        if plotnb != self.image['axes_number'] - 1:
 
36
                                                qtcolor = self.QTColorGet(line[plotnb]['color'])
 
37
                                                pen.setColor(qtcolor)
 
38
                                                pen.setWidthF(line[plotnb]['penwidth'])
 
39
                                                ptr = self.scene.addLine(plotnb * defaults.axiswidth, self.image['height'] - line[plotnb]['y'], (plotnb + 1) * defaults.axiswidth, self.image['height'] - line[plotnb+1]['y'], pen)
 
40
                                                ptr.setToolTip("%s -> %s" % (line[plotnb]['strval'], line[plotnb+1]['strval']))
 
41
                                                ptr.setCursor(QtCore.Qt.OpenHandCursor)
 
42
                                plotnb = plotnb + 1
 
43
 
 
44
        def showLines(self, show_max):
 
45
                itemnb = 0
 
46
                counter = 0
 
47
                for item in self.scene.items():
 
48
                        if ((itemnb - 1)/self.image['axes_number']  == show_max):
 
49
                                return
 
50
                        itemnb = itemnb + 1
 
51
                        item.show()
 
52
 
 
53
        def update_lines_view(self, value):
 
54
                for item in self.scene.items():
 
55
                        item.hide()
 
56
 
 
57
                self.showLines(value)
 
58
 
 
59
        def maxLinesGet(self):
 
60
                linecounter = 0
 
61
                for line in self.image['lines']:
 
62
                        linecounter = linecounter + 1
 
63
 
 
64
                return linecounter
 
65