コード例 #1
0
    def __savePlotAsPNG(self, _fileName, _sizeX, _sizeY, _mutex):
        fileName = str(_fileName)
        #        pixmap=QPixmap(_sizeX,_sizeY)  # worked on Windows, but not Linux/OSX
        #        pixmap.fill(QColor("white"))

        imgmap = QImage(_sizeX, _sizeY, QImage.Format_ARGB32)
        #imgmap.fill(Qt.white)
        imgmap.fill(
            qRgba(255, 255, 255, 255)
        )  # solid white background (should probably depend on user-chosen colors though)

        self.pW.print_(imgmap)
        # following seems pretty crude, but keep in mind user can change Prefs anytime during sim
        # # #         if Configuration.getSetting("OutputToProjectOn"):
        # # #             outDir = str(Configuration.getSetting("ProjectLocation"))
        # # #         else:
        # # #             outDir = str(Configuration.getSetting("OutputLocation"))

        import CompuCellSetup
        outDir = CompuCellSetup.getSimulationOutputDir()

        outfile = os.path.join(outDir, fileName)
        #        print '--------- savePlotAsPNG: outfile=',outfile
        imgmap.save(outfile, "PNG")
        _mutex.unlock()
コード例 #2
0
    def savePlotAsData(self,_fileName):        
# # #         if Configuration.getSetting("OutputToProjectOn"):
# # #             outDir = str(Configuration.getSetting("ProjectLocation"))
# # #         else:
# # #             outDir = str(Configuration.getSetting("OutputLocation"))  # may to dump into image/lattice output dir instead

        import CompuCellSetup
        outDir=CompuCellSetup.getSimulationOutputDir()   
            
        outfile = os.path.join(outDir,_fileName)
        print MODULENAME,'  savePlotAsData():   outfile=',outfile
        fpout = open(outfile, "w")
#        print MODULENAME,'  self.plotData= ',self.plotData
        for idx in range(len(self.plotData)):
#            print MODULENAME,'  savePlotAsData():   ------- idx,name=',idx, self.plotData.keys()[idx]
            fpout.write(self.plotData.keys()[idx] + '\n')
            xvals = self.plotData.values()[idx][0]
            yvals = self.plotData.values()[idx][1]
#            print MODULENAME,'  savePlotAsData():   xvals=',xvals
#            print MODULENAME,'  savePlotAsData():   yvals=',yvals
            for jdx in range(len(xvals)):
                xyStr = "%f  %f\n" % (xvals[jdx],yvals[jdx])
                fpout.write(xyStr)
        
#        if (not _plotName in self.plotData.keys() ) or (not _plotName in self.plotDrawingObjects.keys() ):                        
        fpout.close()
コード例 #3
0
    def savePlotAsData(self, _fileName, _outputFormat=LEGACY_FORMAT):
        # PLOT_TYPE_POSITION=3
        # (XYPLOT,HISTOGRAM,BARPLOT)=range(0,3)

        import CompuCellSetup
        outDir = CompuCellSetup.getSimulationOutputDir()

        outfile = os.path.join(outDir, _fileName)
        # print MODULENAME,'  savePlotAsData():   outfile=',outfile
        fpout = open(outfile, "w")
        # print MODULENAME,'  self.plotData= ',self.plotData

        for plotName, plotData in self.plotData.iteritems():
            # fpout.write(plotName+ '\n')
            fieldSize = self.writeOutHeader(_file=fpout,
                                            _plotName=plotName,
                                            _outputFormat=_outputFormat)

            xvals = plotData[0]
            yvals = plotData[1]
            # print MODULENAME,'  savePlotAsData():   xvals=',xvals
            # print MODULENAME,'  savePlotAsData():   yvals=',yvals
            if _outputFormat == LEGACY_FORMAT:
                if plotData[PLOT_TYPE_POSITION] == XYPLOT or plotData[
                        PLOT_TYPE_POSITION] == BARPLOT:
                    for jdx in range(len(xvals)):
                        xyStr = "%f  %f\n" % (xvals[jdx], yvals[jdx])
                        fpout.write(xyStr)
                elif plotData[PLOT_TYPE_POSITION] == HISTOGRAM:
                    for jdx in range(len(xvals) - 1):
                        xyStr = "%f  %f\n" % (xvals[jdx], yvals[jdx])
                        fpout.write(xyStr)

            elif _outputFormat == CSV_FORMAT:
                fmt = ''
                fmt += '{0:>' + str(fieldSize) + '},'
                fmt += '{1:>' + str(fieldSize) + '}\n'

                if plotData[PLOT_TYPE_POSITION] == XYPLOT or plotData[
                        PLOT_TYPE_POSITION] == BARPLOT:
                    for jdx in range(len(xvals)):

                        xyStr = fmt.format(xvals[jdx], yvals[jdx])
                        # "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)
                elif plotData[PLOT_TYPE_POSITION] == HISTOGRAM:
                    for jdx in range(len(xvals) - 1):
                        xyStr = fmt.format(xvals[jdx], yvals[jdx])
                        # xyStr = "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)

            else:
                raise LookupError(MODULENAME + " savePlotAsData :" +
                                  "Requested output format: " + outputFormat +
                                  " does not exist")
            fpout.write('\n')  #separating data series by a line

        fpout.close()
コード例 #4
0
ファイル: PlotManager.py プロジェクト: Tina2333/CompuCell3D
    def savePlotAsData(self,_fileName,_outputFormat=LEGACY_FORMAT):        
        # PLOT_TYPE_POSITION=3
# (XYPLOT,HISTOGRAM,BARPLOT)=range(0,3)

        import CompuCellSetup
        outDir=CompuCellSetup.getSimulationOutputDir()   
            
        outfile = os.path.join(outDir,_fileName)
        # print MODULENAME,'  savePlotAsData():   outfile=',outfile
        fpout = open(outfile, "w")
        # print MODULENAME,'  self.plotData= ',self.plotData
        
        for plotName,plotData  in self.plotData.iteritems():
            # fpout.write(plotName+ '\n')
            fieldSize=self.writeOutHeader( _file=fpout,_plotName=plotName, _outputFormat=_outputFormat)
            
            xvals = plotData[0]
            yvals = plotData[1]
            # print MODULENAME,'  savePlotAsData():   xvals=',xvals
            # print MODULENAME,'  savePlotAsData():   yvals=',yvals
            if _outputFormat==LEGACY_FORMAT:
                if plotData[PLOT_TYPE_POSITION]==XYPLOT or plotData[PLOT_TYPE_POSITION]==BARPLOT:
                    for jdx in range(len(xvals)):
                        xyStr = "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)            
                elif plotData[PLOT_TYPE_POSITION]==HISTOGRAM:
                    for jdx in range(len(xvals)-1):
                        xyStr = "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)            
                        
            elif  _outputFormat==CSV_FORMAT:
                fmt=''
                fmt+='{0:>'+str(fieldSize)+'},'
                fmt+='{1:>'+str(fieldSize)+'}\n'

                if plotData[PLOT_TYPE_POSITION]==XYPLOT or plotData[PLOT_TYPE_POSITION]==BARPLOT:
                    for jdx in range(len(xvals)):
                    
                        xyStr = fmt.format(xvals[jdx],yvals[jdx])
                        # "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)            
                elif plotData[PLOT_TYPE_POSITION]==HISTOGRAM:
                    for jdx in range(len(xvals)-1):
                        xyStr = fmt.format(xvals[jdx],yvals[jdx])
                        # xyStr = "%f  %f\n" % (xvals[jdx],yvals[jdx])
                        fpout.write(xyStr)            

                
            else:
                raise LookupError(MODULENAME+" savePlotAsData :"+"Requested output format: "+outputFormat+" does not exist")
            fpout.write('\n') #separating data series by a line                           
        
        fpout.close()
コード例 #5
0
ファイル: PlotManager.py プロジェクト: Tina2333/CompuCell3D
    def __savePlotAsPNG(self,_fileName,_sizeX,_sizeY,_mutex):        
        fileName=str(_fileName)
#        pixmap=QPixmap(_sizeX,_sizeY)  # worked on Windows, but not Linux/OSX
#        pixmap.fill(QColor("white"))
        
        imgmap = QImage(_sizeX, _sizeY, QImage.Format_ARGB32)
        #imgmap.fill(Qt.white)
        imgmap.fill(qRgba(255, 255, 255, 255)) # solid white background (should probably depend on user-chosen colors though)
        
        self.pW.print_(imgmap)
        # following seems pretty crude, but keep in mind user can change Prefs anytime during sim
# # #         if Configuration.getSetting("OutputToProjectOn"):
# # #             outDir = str(Configuration.getSetting("ProjectLocation"))
# # #         else:
# # #             outDir = str(Configuration.getSetting("OutputLocation"))

        import CompuCellSetup
        outDir=CompuCellSetup.getSimulationOutputDir()
        
        outfile = os.path.join(outDir,fileName)
#        print '--------- savePlotAsPNG: outfile=',outfile
        imgmap.save(outfile,"PNG")
        _mutex.unlock()