summaryrefslogtreecommitdiff
path: root/bin/chroma-cam
blob: b8e54341b0c6988ee349b63ebaa19ba472a77e6d (plain)
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
#!/usr/bin/env python
#--*-python-*-

if __name__ == '__main__':
    import optparse
    import sys
    import os

    from chroma.camera import view, EventViewer
    from chroma.stl import mesh_from_stl
    from chroma.tools import enable_debug_on_crash
    import chroma.loader
    from chroma.log import logger, logging
    logger.setLevel(logging.INFO)

    parser = optparse.OptionParser('%prog')
    parser.add_option('--debug', dest='debug', action='store_true', 
                      default=False, help='Start python debugger on exception')
    parser.add_option('-r', '--resolution', dest='resolution',
                      help='specify window resolution', default='1024,576')
    parser.add_option('-i', dest='io_file', default=None)
    options, args = parser.parse_args()

    if len(args) < 1:
        sys.exit(parser.format_help())

    if options.debug:
        enable_debug_on_crash()

    size = [int(s) for s in options.resolution.split(',')]

    geometry = chroma.loader.load_geometry_from_string(args[0])

    if options.io_file is None:
        view(geometry, size)
    else:
        viewer = EventViewer(geometry, options.io_file, size=size)
        viewer.start()