File: AutoSwitch.py

package info (click to toggle)
pyqwt3d 0.1.8-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 984 kB
  • sloc: python: 3,932; cpp: 328; makefile: 115; sh: 7
file content (140 lines) | stat: -rwxr-xr-x 2,956 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/env python

import sys
from qt import QApplication, QSplitter, QTimer, SIGNAL
from 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)

        self.setRotation(30, 0, 15)
        self.setShift(0.1, 0, 0)
        self.setZoom(0.8)
        self.coordinates().setNumberFont("Courier", 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(QSplitter.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.setMainWidget(demo)
    app.exec_loop()

# main()


# Admire
if __name__ == '__main__':
    main(sys.argv)


# Local Variables: ***
# mode: python ***
# End: ***