VEFViewer.py
author Dmitriy Morozov <dmitriy@mrzv.org>
Thu, 24 Mar 2011 15:15:07 -0700
changeset 11 d2b9ee185b38
parent 10 bc10701b4081
child 15 30a851aa0675
permissions -rwxr-xr-x
Pressing P changes the type of camera projection

#!/usr/bin/env python2

import  ui_PyVEFViewer  as ui
from    opster          import command, dispatch
from    sys             import exit

class VEFViewerWindow(ui.QtGui.QWidget):
    def __init__(self, parent = None):
        super(VEFViewerWindow, self).__init__(parent)

        self.ui = ui.Ui_MainWindow()
        self.ui.setupUi(self)

@command(usage = '%name [options]',
         options = [('p', 'points',    [], 'files with points'),       # TODO: add completer for filenames
                    ('e', 'edges',     [], 'files with edges'),
                    ('t', 'triangles', [], 'files with triangles')])
def main(*args, **opts):
    
    points    = opts['points']
    edges     = opts['edges']
    triangles = opts['triangles']

    qapp = ui.QtGui.QApplication([])
    win  = VEFViewerWindow()
    win.show()

    win.ui.viewer.set_list(win.ui.modelList)
    win.ui.viewer.read_points(points)
    win.ui.viewer.read_edges(edges)
    win.ui.viewer.read_triangles(triangles)
    # Guess types from extensions
    for fn in args:
        if not win.ui.viewer.read_from_extension(fn):
            print "Cannot guess type from extension:", fn
            exit(1)
    win.ui.viewer.normalize_view()
    win.ui.viewer.show_entire_scene()

    qapp.exec_()

if __name__ == '__main__':
    main()