Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

startupMainGUI.py

00001 ## \mainpage LatTE Documentation
00002 ## \image html "glast_galaxie.gif"
00003 ##
00004 
00005 #!/usr/local/bin/python
00006 #
00007 #                               Copyright 2004
00008 #                                     by
00009 #                        The Board of Trustees of the
00010 #                     Leland Stanford Junior University.
00011 #                            All rights reserved.
00012 #
00013 
00014 
00015 __facility__ = "Online"
00016 __abstract__ = "Main GUI startup code"
00017 __author__   = "S. Tuvi <stuvi@SLAC.Stanford.edu> SLAC - GLAST I&T/Online"
00018 __date__     = ("$Date: 2006/04/12 01:01:09 $").split(' ')[1]
00019 __version__  = "$Revision: 2.15 $"
00020 __release__  = "$Name: R04-12-00 $"
00021 __credits__  = "SLAC"
00022 
00023 
00024 import LATTE.copyright_SLAC
00025 
00026 import os, threading
00027 from qt import *
00028 from sihippo import CanvasWindow, NTupleController, WindowController
00029 import logging as log
00030 
00031 from LATTE.runcontrol.RunControlCommon import RunControlCommon
00032 from LATTE.runcontrol.RunControlMain   import RunControlMain
00033 
00034 def startupMainGui():
00035   """Start up run control."""
00036 
00037   #Declare DBN as global so that we can access it from the Python Shell
00038   global DBN
00039 
00040   rcCommon = RunControlCommon()
00041 
00042   app = rcCommon.getQtApp()
00043   QObject.connect(app, SIGNAL("lastWindowClosed()"), app, SLOT("quit()"))
00044 
00045   rcCommon.initialize(startup=True)
00046   #rcCommon.startLogger()
00047   rcCommon.EBFdistribution()
00048 
00049   initstyle(rcCommon)
00050   runCtl = RunControlMain(rcCommon)
00051 
00052   if rcCommon.options().schema is not None:
00053     try:
00054       rcCommon.readSchema(os.path.abspath(rcCommon.options().schema))
00055     except Exception, e:
00056       log.exception("Exception in readSchema:")
00057       raise e
00058 
00059   runCtl.connectClicked()
00060   app.setMainWidget(runCtl)
00061   runCtl.show()
00062 
00063   if rcCommon.options().securedir is not None:
00064     login = runCtl.login()
00065     if login == None or login == -2:
00066       app.quit()
00067       return
00068   else:
00069     runCtl.fileLogoutAction.setEnabled(0)
00070 
00071   if rcCommon.options().schema is None:
00072     try:
00073       runCtl.loadSchema()
00074     except Exception, e:
00075       log.exception("Exception in readSchema:")
00076   else:
00077     runCtl.panels()['Global'].checkFabricEnable(rcCommon.getLAT().existsGEM())
00078 
00079   WindowController.instance().createInspector()
00080   canvas = CanvasWindow()
00081   ntc = NTupleController.instance()
00082   nt  = ntc.createNTuple()
00083   nt.setLabels(['Event Size'])
00084   nt.setTitle('Event Size')
00085   nt.setIntervalCount(1000000)
00086   nt.setIntervalEnabled(1)
00087 
00088   DBN = rcCommon.getDBN()
00089   DBN['_canvas'] = canvas
00090   DBN['_event_size'] = 0
00091   DBN['_EventSizeNTuple'] = nt
00092   DBN['_prefs'] = rcCommon.prefMan().preferences()
00093 
00094   threading.currentThread().setName("LATTE_GUI")
00095   app.exec_loop()
00096 
00097 def initstyle(rcCommon):
00098   prefs = rcCommon.prefMan().preferences()
00099   if prefs.has_key('style'):
00100     style = prefs['style']
00101     if style in QStyleFactory.keys():
00102       qApp.setStyle(QStyleFactory.create(style))
00103   font = QApplication.font()
00104   if prefs.has_key('fontfamily'):
00105     font.setFamily(prefs['fontfamily'])
00106   if prefs.has_key('fontsize'):
00107     font.setPointSize(int(prefs['fontsize']))
00108   if prefs.has_key('fontweight'):
00109     font.setWeight(int(prefs['fontweight']))
00110   if prefs.has_key('fontitalic'):
00111     font.setItalic(int(prefs['fontitalic']))
00112   qApp.setFont(font)
00113 
00114 if __name__ == '__main__':
00115   # For profiling, uncomment the two lines below
00116   # and comment out the line after them.
00117   # After running, use the following code to 
00118   # analyze the profiling data:
00119   #   import pstats
00120   #   p = pstats.Stats('profile')
00121   #   p.strip_dirs().sort_stats(-1).print_stats()
00122   
00123   #import profile
00124   #profile.run('startupMainGui()', 'profile')
00125   startupMainGui()

Generated on Fri Jul 21 13:26:32 2006 for LATTE R04-12-00 by doxygen 1.4.3