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

evtDataImpl.py

00001 #!/usr/local/bin/python
00002 #
00003 #                               Copyright 2004
00004 #                                     by
00005 #                        The Board of Trustees of the
00006 #                     Leland Stanford Junior University.
00007 #                            All rights reserved.
00008 #
00009 
00010 
00011 __facility__ = "Online"
00012 __abstract__ = "Event Data displayer module"
00013 __author__   = "A. Kavelaars <aliciak@SLAC.Stanford.edu> SLAC - GLAST I&T/Online"
00014 __date__     = ("$Date: 2004/08/24 23:15:11 $").split(' ')[1]
00015 __version__  = "$Revision: 2.1 $"
00016 __release__  = "$Name: R04-12-00 $"
00017 __credits__  = "SLAC"
00018 
00019 import LATTE.copyright_SLAC
00020 
00021 import sys
00022 from qt import *
00023 from evtData import evtData
00024 import Numeric
00025 
00026 class evtDataImpl(evtData):
00027 
00028   def __init__(self,parent = None,name = None,fl = 0):
00029     evtData.__init__(self,parent,name,fl)
00030   # public slot
00031 
00032   def load(self):
00033     f = file( str(self.__filename), 'rb' )
00034 
00035     #~ if not f.open( IO_ReadOnly ):
00036         #~ return
00037 
00038     dataString = []
00039     #~ while 1:
00040     data = f.read()
00041     dataArray = Numeric.fromstring(data,'b')
00042 
00043     #~ self.evtDataList.setPointSize(16)
00044     #~ self.evtDataList.setFamily('Courier')
00045 
00046     v = ""
00047     for i in xrange(len(dataArray)):
00048       v += "%02x " % dataArray[i]
00049 
00050     self.evtDataList.setText(v)
00051 
00052     #~ font = self.evtDataList.font()
00053 
00054     f.close()
00055 
00056   def fileNew(self):
00057     print "evtDataImpl.fileNew(): Not implemented yet"
00058   # public slot
00059 
00060   def fileOpen(self):
00061     fn = QFileDialog.getOpenFileName( QString.null, "(*.*)", self, "Event Data file dialog",
00062                                             "Choose an Event Data File" )
00063     if not fn.isEmpty():
00064       self.__filename = fn
00065       self.load( )
00066 
00067   def fileSave(self):
00068     print "evtDataImpl.fileSave(): Not implemented yet"
00069   # public slot
00070 
00071   def fileSaveAs(self):
00072     print "evtDataImpl.fileSaveAs(): Not implemented yet"
00073   # public slot
00074 
00075   def filePrint(self):
00076     Margin = 50
00077     pageNo = 1
00078     column = [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150] # Magic numbers
00079 
00080     # If there are no items, don't try to print
00081     if not self.Logger.firstChild():
00082       return
00083 
00084     if self.printer.setup(self):
00085       self.statusBar().message('Printing...')
00086 
00087       p = QPainter()
00088       p.begin(self.printer)
00089       p.setFont(self.Logger.font())
00090       yPos = 0
00091       fm = p.fontMetrics()
00092       metrics = QPaintDeviceMetrics(self.printer)
00093 
00094       header = "Evend Data Source: " + str(self.__filename)
00095 
00096       page = "Page: 1"
00097       p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),Qt.ExpandTabs | Qt.DontClip, header)
00098       yPos = yPos + fm.lineSpacing()
00099       p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),Qt.ExpandTabs | Qt.DontClip, page)
00100       yPos = yPos + 2*fm.lineSpacing()
00101 
00102       #~ columnHeader = ['','Severity','Date','Time','Source','Message']
00103 
00104       for i in len(self.__data):
00105         p.drawText(column[i],Margin + yPos,metrics.width(),fm.lineSpacing(),
00106                     Qt.ExpandTabs | Qt.DontClip, columnHeader[i])
00107       yPos = yPos + fm.lineSpacing()
00108 
00109       item = self.Logger.firstChild()
00110       for j in range(self.Logger.childCount()):
00111         if Margin + yPos > metrics.height() - Margin:
00112           pageNo = pageNo + 1
00113           page = "Page: " + str(pageNo)
00114           self.statusBar().message('Printing (page %d)...' % (pageNo))
00115           self.printer.newPage()
00116           yPos = 0
00117           p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),Qt.ExpandTabs | Qt.DontClip, header)
00118           yPos = yPos + fm.lineSpacing()
00119           p.drawText(Margin,Margin + yPos,metrics.width(),fm.lineSpacing(),Qt.ExpandTabs | Qt.DontClip, page)
00120           yPos = yPos + 2*fm.lineSpacing()
00121 
00122           for i in range (0,6):
00123             p.drawText(column[i],Margin + yPos,metrics.width(),fm.lineSpacing(),
00124                       Qt.ExpandTabs | Qt.DontClip, columnHeader[i])
00125           yPos = yPos + fm.lineSpacing()
00126 
00127         for i in range (0,6):
00128           p.drawText(column[i],Margin + yPos,metrics.width(),fm.lineSpacing(),
00129                     Qt.ExpandTabs | Qt.DontClip,item.text(i))
00130         yPos = yPos + fm.lineSpacing()
00131         item = item.nextSibling()
00132 
00133       p.end()
00134       self.statusBar().message('Printing completed',2000)
00135     else:
00136       self.statusBar().message('Printing aborted',2000)
00137 
00138 
00139   def fileExit(self):
00140     print "evtDataImpl.fileExit(): Not implemented yet"
00141   # public slot
00142 
00143   def helpIndex(self):
00144     print "evtDataImpl.helpIndex(): Not implemented yet"
00145   # public slot
00146 
00147   def helpContents(self):
00148     print "evtDataImpl.helpContents(): Not implemented yet"
00149   # public slot
00150 
00151   def helpAbout(self):
00152     print "evtDataImpl.helpAbout(): Not implemented yet"
00153 
00154 
00155 
00156 if __name__ == "__main__":
00157   a = QApplication(sys.argv)
00158   QObject.connect(a,SIGNAL("lastWindowClosed()"),a,SLOT("quit()"))
00159   w = evtDataImpl()
00160   a.setMainWidget(w)
00161   w.show()
00162   a.exec_loop()

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