File: ParametricSurfaceDemo.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 (73 lines) | stat: -rwxr-xr-x 1,399 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
#!/usr/bin/env python

import sys
from math import cos, pi, sin
from qt import QApplication
from Qwt3D import ParametricSurface, RGBA, SurfacePlot, Triple, NOCOORD

class Sphere(ParametricSurface):

    def __init__(self, *args):
        ParametricSurface.__init__(self, *args)
        self.setMesh(41, 31)
        self.setDomain(0, 2*pi, 0, pi)
        self.setPeriodic(False, False)

    # __init__()

    def __call__(self, u, v):
        r = 1.0
        return Triple(r*cos(u)*sin(v), r*sin(u)*sin(v), r*cos(v))

    # __call__()

# class Sphere

        
class Plot(SurfacePlot):

    def __init__(self, *args):
        SurfacePlot.__init__(self, *args)
        self.setTitle("A Simple Parametric Surface Demonstration")
        self.setBackgroundColor(RGBA(1.0, 1.0, 0.6))

        sphere = Sphere(self)
        sphere.create()

        self.setRotation(45, 15, 0)
        self.setCoordinateStyle(NOCOORD);
        self.updateData()
        self.updateGL()

    # __init__()

# class Plot


def make():
    demo = Plot()
    demo.show()
    # Matrox cards on Linux work better with a resize() after show()
    demo.resize(600, 400)
    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: ***