/usr/share/doc/python-qwt3d-doc/qt4examples/AutoSwitch.py is in python-qwt3d-doc 0.1.7~cvs20090625-13.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | #!/usr/bin/env python
import sys
from PyQt4.Qt import QApplication, QCoreApplication, QFont, QFontDatabase
from PyQt4.Qt import QSplitter, QTimer, SIGNAL, Qt
from PyQt4.Qwt3D import *
class Saddle(Function):
def __init__(self, *args):
Function.__init__(self, *args)
self.setDomain(-2.5, 2.5, -2.5, 2.5)
self.setMaxZ(1.5)
self.setMinZ(-1.5)
self.setMesh(31,31)
# __init__()
def __call__(self, x, y):
return x*y
# __call__()
# class Saddle
class Hat(Function):
def __init__(self, *args):
Function.__init__(self, *args)
self.setDomain(-1.5, 1.5, -1.5, 1.5)
self.setMesh(41, 41)
# __init__()
def __call__(self, x, y):
return 1.0/(x*x+y*y+0.3)
# __call__()
# class Hat
class Plot(SurfacePlot):
def __init__(self, parent, updateinterval):
SurfacePlot.__init__(self, parent)
# fonts
family = QCoreApplication.instance().font().family()
if 'Verdana' in QFontDatabase().families():
family = 'Verdana'
family = 'Courier'
self.setTitleFont(family, 16, QFont.Bold)
self.setRotation(30, 0, 15)
self.setShift(0.1, 0, 0)
self.setZoom(0.8)
self.coordinates().setNumberFont(family, 8)
axes = self.coordinates().axes # alias
for axis in axes:
axis.setMajors(7)
axis.setMinors(4)
axes[X1].setLabelString("x")
axes[Y1].setLabelString("y")
axes[Z1].setLabelString("z")
axes[X2].setLabelString("x")
axes[Y2].setLabelString("y")
axes[Z2].setLabelString("z")
axes[X3].setLabelString("x")
axes[Y3].setLabelString("y")
axes[Z3].setLabelString("z")
axes[X4].setLabelString("x")
axes[Y4].setLabelString("y")
axes[Z4].setLabelString("z")
timer = QTimer(self)
self.connect(timer, SIGNAL('timeout()'), self.rotate)
timer.start(updateinterval)
# __init__()
def rotate(self):
self.setRotation(int(self.xRotation()+2) % 360,
int(self.yRotation()+2) % 360,
int(self.zRotation()+2) % 360)
# rotate()
# class Plot()
def make():
demo = QSplitter(Qt.Horizontal)
plot1 = Plot(demo, 30)
plot1.setFloorStyle(FLOORISO)
plot1.setCoordinateStyle(BOX)
saddle = Saddle(plot1)
saddle.create()
plot1.setTitle("Autoswitching axes")
plot1.setBackgroundColor(RGBA(1.0, 1.0, 0.6))
plot1.makeCurrent()
plot1.updateData()
plot1.updateGL()
plot2 = Plot(demo, 80)
plot2.setZoom(0.8)
hat = Hat(plot2)
hat.create()
plot2.setPlotStyle(HIDDENLINE)
plot2.setFloorStyle(FLOORDATA)
plot2.setCoordinateStyle(FRAME)
plot2.setBackgroundColor(RGBA(1.0, 1.0, 0.6))
plot2.makeCurrent()
plot2.updateData()
plot2.updateGL()
demo.resize(800, 400)
demo.show()
return demo
# make()
def main(args):
app = QApplication(args)
demo = make()
app.exec_()
# main()
# Admire
if __name__ == '__main__':
main(sys.argv)
# Local Variables: ***
# mode: python ***
# End: ***
|