#!/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)
# TODO: add completer for filenames
@command(usage = '%name [options]',
options = [('p', 'points', [], 'files with points (vrt or pts)'),
('e', 'edges', [], 'files with edges (edg)'),
('t', 'triangles', [], 'files with triangles (stl)'),
('s', 'spheres', [], 'files with spheres (sph)')])
def main(*args, **opts):
"""Visualize points, edges, or triangles in the given files. Appending :MULT to the filename multiplies the positions in that file by MULT."""
points = opts['points']
edges = opts['edges']
triangles = opts['triangles']
spheres = opts['spheres']
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)
win.ui.viewer.read_spheres(spheres)
# 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()