Text archives Help
- From: brownlee@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [Manta] r1729 - trunk/SwigInterface
- Date: Wed, 19 Sep 2007 18:05:19 -0600 (MDT)
Author: brownlee
Date: Wed Sep 19 18:05:17 2007
New Revision: 1729
Modified:
trunk/SwigInterface/wxManta.py
Log:
added default commandine parsing to MantaApp, added a fix for x11 (hopefully
not breaking anything else)
Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py (original)
+++ trunk/SwigInterface/wxManta.py Wed Sep 19 18:05:17 2007
@@ -6,6 +6,7 @@
import string
import re
+from wx import glcanvas
from wxPython.glcanvas import wxGLCanvas
from wx.glcanvas import WX_GL_DOUBLEBUFFER as GL_DOUBLEBUFFER
@@ -36,6 +37,46 @@
return 255
else:
return 0
+
+###############################################################################
+###############################################################################
+# ParseCommandLine.
+# Parses commandline into a list of <option> <list of arguments> pairs
+# option must be preceded by one or more '-' and followed by a space or
'=' along
+# with arguments seperated by space or commas. example --np=4
--camera=4 5 3 1,2,3 4 4 4
+# Example usage:
+# args = wxManta.parseCommandLine(sys.argv)
+# rest = []
+# for o, a in args:
+# if o in ("customOption"):
+# try:
+# cn = int(a[0])
+# print str("customOption: ") + str(int(a[0]))
+# except ValueError:
+# sys.exit(2)
+# else:
+# rest.append( (o,a) ) #send to MantaApp
+# app = wxManta.MantaApp( initialize_scene,
+# num_workers, (512,512), False, None, rest )
+###############################################################################
+###############################################################################
+def parseCommandLine(commandLine):
+ argvs = commandLine[1:]
+ args = []
+ j = -1
+ for i in range(len(argvs)):
+ if (len(argvs[i]) > 0 and argvs[i][0] == "-"):
+ temp = (argvs[i].lstrip("-")).rsplit("=")
+ temp2 = temp[1:]
+ if (len(temp2) > 0):
+ temp2 = temp2[0].rsplit(",")
+ args.append( (temp[0], temp2) )
+ j+=1
+ elif(j >= 0):
+ args[j][1].append(argvs[i].rsplit(","))
+ print str("pcl: args: ") + str(args)
+ return args
+
###############################################################################
###############################################################################
@@ -122,7 +163,7 @@
wxGLCanvas.__init__(self, parent, -1, style=wx.NO_BORDER,
size=size)
else:
# This line for linux.
- wxGLCanvas.__init__(self, parent, -1,
attribList=[GL_DOUBLEBUFFER, 0], style=wx.NO_BORDER, size=size)
+ wxGLCanvas.__init__(self, parent, -1,
attribList=[GL_DOUBLEBUFFER, glcanvas.WX_GL_RGBA, 0], style=wx.NO_BORDER,
size=size)
self.sync_display = sync_display
self.opengl_display = opengl_display
@@ -1172,15 +1213,36 @@
text = "%2.2lf fps - %3.1lf spf" % (framerate , 1.0/framerate);
self.statusbar.SetStatusText(text, 0)
-
+###########################################################################
+## usage
+## - prints out error message with supported command line options
+###########################################################################
+def usage():
+ print "Usage: python test.py [options]"
+ print "Where options contains one or more of:"
+ print "-n --np=<threads>"
+
+
class MantaApp(wx.App) :
def __init__(self,
initialize_callback_ = createDefaultScenePython,
num_workers = Thread.numProcessors(),
renderSize = wx.Size(xres,yres),
redirect=False,
- filename=None):
+ filename=None, commandLine = []):
wx.App.__init__(self, redirect, filename)
+
+ for o, a in commandLine:
+ if o in ("np"):
+ try:
+ num_workers = int(a[0])
+ print str("num_workers: ") + str(int(a[0]))
+ except ValueError:
+ sys.exit(2)
+ else:
+ print str("ERROR: unrecognized command line option: ") +
str(o)
+ usage()
+ sys.exit(2)
try:
- [Manta] r1729 - trunk/SwigInterface, brownlee, 09/19/2007
Archive powered by MHonArc 2.6.16.