def testParseOptions(self): value = "" self.assertEqual(utils.parseOptions(value), []) value = "SkipOption" self.assertEqual(utils.parseOptions(value), ["SkipOption"]) value = "Option1 Option2" self.assertEqual(utils.parseOptions(value), ["Option1", "Option2"])
def addSlideTextPlots(slideTitle, bullets, plots=[], drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = "\\begin{frame}\\frametitle{%s} \n" % (slideTitle) code += utils.handleStartingOpts(opts) nRows = int(opts["numrows"]) if opts["numrows"] else 2 plotChunks = [plots[i:i + nRows] for i in range(0, len(plots), nRows)] nCols = len(plotChunks) height = (1.0 / nRows) * utils.textLinesToPlotHeight( utils.bulletNLines(bullets)) width = 1.0 code += utils.bulletsToCode(bullets, opts) code += "\\begin{columns}[t]\n" for chunk in plotChunks: code += "\\column{%.2f\\textwidth}\n" % (1.0 / nCols) code += "\\centering" for plot in chunk: code += "\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s}\\\\ \n" % ( drawType, height, width, plot) code += "\\end{columns}" return code
def addSlideTextPlotPlotPlot(slideTitle, bullets, plotName1, plotName2, plotName3, drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = "\\begin{frame}\\frametitle{%s} \n" % (slideTitle) code += utils.handleStartingOpts(opts) height = 0.5 * utils.textLinesToPlotHeight(utils.bulletNLines(bullets)) width = 1.0 code += utils.bulletsToCode(bullets, opts) code += "\\begin{columns}[c]\n" code += "\\column{0.5\\textwidth}\n" code += "\\centering" code += "\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s}\\\\ \n" % ( drawType, height, width, plotName1) code += "\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s} \n" % ( drawType, height, width, plotName2) code += "\\column{0.55\\textwidth}\n" code += "\\centering" code += "\\hspace*{-0.10\\textwidth}\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s} \n" % ( drawType, 1.5 * height, width, plotName3) code += "\\end{columns}" return code
def addSlideTeX(slideTitle, tex, opts=""): opts = utils.parseOptions(opts) code = """ \\begin{frame}\\frametitle{%s} """ % slideTitle code += tex return code
def writeSlides(output="output.tex", opts="--compile"): global source source += footer fh = open(output,"w") fh.write(source) fh.close() print "[SM] Wrote slides" opts = utils.parseOptions(opts) if(opts["compile"]): # compile twice to get correct slide numbers. latex is dumb. is this the only way? stat,out = commands.getstatusoutput("pdflatex -interaction=nonstopmode %s && \ pdflatex -interaction=nonstopmode %s " % (output,output) ) if("Fatal error" in out): print "[SM] ERROR: Tried to compile, but failed. Last few lines of printout below." print "_"*40 print "\n".join(out.split("\n")[-30:]) return else: print "[SM] Compiled slides to", output.replace(".tex",".pdf") if(opts["copy"]): stat,out = commands.getstatusoutput("cp %s ~/public_html/%s/" % (output.replace(".tex",".pdf"), "dump" if opts["dump"] else "")) print "[SM] Copied output to uaf-6.t2.ucsd.edu/~%s/%s%s" % (os.getenv("USER"), "dump/" if opts["dump"] else "", output.replace(".tex",".pdf")) if(globalOpts["makegui"] and len(objectslides) > 0): utils.makeGUI(objectslides, output.replace(".tex",".pdf"), os.getcwd())
def addSlideText(slideTitle, bullets, opts=""): opts = utils.parseOptions(opts) pos = "" if (opts["texttop"]): pos = "[t]" if (opts["textbottom"]): pos = "[b]" code = "\\begin{frame}%s\\frametitle{%s} \n" % (pos, slideTitle) code += utils.handleStartingOpts(opts) code += utils.bulletsToCode(bullets, opts) return code
def parseOptions(self): """ Parses the value given after the options option. This function assumes the options option is present in the task's section. """ assert self.hasOption(name) for option in utils.parseOptions(self.option(name)): self.addOption(option)
def addSlidePlot(slideTitle, plotName, drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = """ \\begin{frame}\\frametitle{%s} \\begin{center} """ if (opts["fithorizontal"]): code += "\\vspace*{-0.035\\textheight}\\%s[width=0.99\\textwidth,keepaspectratio]{%s}" else: code += "\\vspace*{-0.025\\textheight}\\%s[height=0.87\\textheight,keepaspectratio]{%s}" code += "\\end{center}" code = code % (slideTitle, drawType, plotName) return code
def addSlideTitle(title="", opts=""): global source opts = utils.parseOptions(opts) shorttitle = opts["shorttitle"] if opts["shorttitle"] else title titlePageNick = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*} \\begin{textblock*}{2.1cm}(0.8\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{cmsbwlogothick.png} \\end{textblock*} """ % (shorttitle, title) titlePageAlex = """ \\begin{frame}[plain] %% draw over global triangle so that it doesn't show up on the title slide %% http://tex.stackexchange.com/questions/41344/tikz-picture-on-the-entire-frame-in-beamer-without-using-overlays \\makebox[\\textwidth][c]{ \\begin{tikzpicture}[thick] \\draw[fill=white, draw=white](0cm,0cm) -- (12.8cm,0cm) -- (12.8cm,9.6cm) -- (0cm,9.6cm) -- (0cm,0cm); \\end{tikzpicture} } \\titlepage """ titlePageMadrid = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*} \\begin{textblock*}{2.1cm}(0.8\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{cmsbwlogothick.png} \\end{textblock*} """ % (shorttitle, title) if (theme == "nick"): source += titlePageNick elif (theme == "alex" or theme == "alexmod"): source = source.replace("TITLEHERE", utils.splitTitle(title)) source += titlePageAlex elif (theme == "madrid"): source += titlePageMadrid else: source += "\\begin{frame} \\titlepage"
def addSlideTextText(slideTitle, bullets1, bullets2, opts=""): opts = utils.parseOptions(opts) pos = "" if (opts["texttop"]): pos = "[t]" if (opts["textbottom"]): pos = "[b]" code = "\\begin{frame}%s\\frametitle{%s} \n" % (pos, slideTitle) code += utils.handleStartingOpts(opts) code += "\\begin{columns}\n \\begin{column}{0.5\\textwidth} \n" code += utils.bulletsToCode(bullets1, opts) code += "\\end{column}\n \\begin{column}{0.5\\textwidth}" code += utils.bulletsToCode(bullets2, opts) code += "\\end{column}\n\\end{columns} \n" return code
def addGlobalOptions(optstr): global globalOpts globalOpts = utils.parseOptions(optstr) if(globalOpts["graphicspaths"]): graphicspaths.extend(globalOpts["graphicspaths"].split(",")) print "[SM] Adding these to the graphics path:", globalOpts["graphicspaths"].split(",") if(globalOpts["makegui"]): try: fname = "objectsgui.txt" execfile(os.getcwd()+"/"+fname) print "[SM] Found file (%s) with objects from GUI. Importing them." % (fname) except: print "[SM] Didn't find file with objects from GUI."
def addSlideTitle(title="", opts=""): global source opts = utils.parseOptions(opts) shorttitle = opts["shorttitle"] if opts["shorttitle"] else title titlePageNick = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*} \\begin{textblock*}{2.1cm}(0.8\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{cmsbwlogothick.png} \\end{textblock*} """ % (shorttitle,title) titlePageAlex = """ \\begin{frame}[plain] %% draw over global triangle so that it doesn't show up on the title slide \\begin{tikzpicture}[thick] \\draw[fill=white, draw=white](0cm,0.0cm) -- (20.3cm,0.0cm) -- (20.3cm,20.3cm) -- (0.0cm,0.0cm); \\end{tikzpicture} \\titlepage """ titlePageMadrid = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*} \\begin{textblock*}{2.1cm}(0.8\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{cmsbwlogothick.png} \\end{textblock*} """ % (shorttitle,title) if(theme == "nick"): source += titlePageNick elif(theme == "alex"): source = source.replace("TITLEHERE",utils.splitTitle(title)) source += titlePageAlex elif(theme == "madrid"): source += titlePageMadrid else: source += "\\begin{frame} \\titlepage"
def startBackup(opts=""): global source, slideNumber slideNumber += 1 opts = utils.parseOptions(opts) print "[SM] Beginning backup" color = "black" # if(theme == "alex"): color = "alexcolor" # if(theme == "nick"): color = "nickcolor" # if(theme == "madrid"): color = "madridcolor" if (opts["resetnumbering"]): source += "\n\\appendix\n" source += """
def addGlobalOptions(optstr): global globalOpts globalOpts = utils.parseOptions(optstr) if (globalOpts["graphicspaths"]): graphicspaths.extend(globalOpts["graphicspaths"].split(",")) print "[SM] Adding these to the graphics path:", globalOpts[ "graphicspaths"].split(",") if (globalOpts["makegui"]): try: fname = "objectsgui.txt" execfile(os.getcwd() + "/" + fname) print "[SM] Found file (%s) with objects from GUI. Importing them." % ( fname) except: print "[SM] Didn't find file with objects from GUI."
def addSlideTextPlot(slideTitle,bullets,plotName,drawType="includegraphics",opts=""): opts = utils.parseOptions(opts) code = "\\begin{frame}\\frametitle{%s} \n" % (slideTitle) if(opts["sidebyside"]): code += "\\begin{columns}\n \\begin{column}{0.5\\textwidth} \n" code += utils.bulletsToCode(bullets) code += "\\end{column}\n \\begin{column}{0.5\\textwidth}" code += " \\begin{center}" code += " \\%s[width=\\textwidth,keepaspectratio]{%s} \n" % (drawType, plotName) code += " \\end{center}\n \\end{column}\n\\end{columns} \n" else: code += utils.bulletsToCode(bullets) code += "\\begin{center}" code += " \\%s[height=%.2f\\textheight,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName) code += "\\end{center}\n" return code
def initSlides(me="Nick", themeName="nick", opts=""): global source, commonHeader, theme, themeAlex, slideNumber, institute source = "" theme = themeName.lower() opts = utils.parseOptions(opts) slideNumber = 0 print "[SM] Hi",me print "[SM] Using theme:",theme source += commonHeader if(opts["modernfont"]): source += "\\usepackage{helvet} %% only modern font that works on uaf?" if(theme == "nick"): source += themeNick if(opts["themecolor"]): source = source.replace("\\definecolor{nickcolor}{RGB}{51,51,179}","\\definecolor{nickcolor}{RGB}{%s}" % opts["themecolor"]) elif(theme == "alex"): source += themeAlex if(opts["themecolor"]): source = source.replace("\\definecolor{alexcolor}{RGB}{0,0,255}","\\definecolor{alexcolor}{RGB}{%s}" % opts["themecolor"]) elif(theme == "madrid"): source += themeMadrid if(opts["themecolor"]): source = source.replace("\\definecolor{madridcolor}{RGB}{51,51,179}","\\definecolor{madridcolor}{RGB}{%s}" % opts["themecolor"]) else: print "unsupported theme:", theme if(opts["casual"]): institute = "\\large{%s}" % opts["casual"] source = source.replace("INSTITUTEHERE", institute) fullname = "" if("Nick" in me): source = source.replace("AUTHORHERE", "Nick Amin") source = source.replace("N. Amin", "\\underline{\\textbf{N. Amin}}") else: print "who are you? add your name to slideMaker." source = source.replace("GRAPHICSPATHHERE", "".join(["{"+p+"}" for p in graphicspaths])) print "[SM] Initializing slides"
def addSlideTextPlotPlot(slideTitle, bullets, plotName1, plotName2, drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = "\\begin{frame}\\frametitle{%s} \n" % (slideTitle) code += utils.handleStartingOpts(opts) if (opts["plottop"]): code += "\\begin{center}" code += "\\%s[height=%.2f\\textheight,width=0.48\\textwidth,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName1) code += "\\%s[height=%.2f\\textheight,width=0.48\\textwidth,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName2) code += "\\end{center}" code += utils.bulletsToCode(bullets, opts) elif (opts["plotsleft"]): height = 0.45 width = 0.55 code += "\\begin{columns}\n" code += "\\column{%.2f\\textwidth}\n" % width code += "\\centering" code += "\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s}\\\\ \n" % ( drawType, height, 1.0, plotName1) code += "\\%s[height=%.2f\\textheight,width=%.2f\\textwidth,keepaspectratio]{%s} \n" % ( drawType, height, 1.0, plotName2) code += "\\column{%.2f\\textwidth}\n" % (1.0 - width) code += "\\centering" code += utils.bulletsToCode(bullets, opts) code += "\\end{columns}" else: code += utils.bulletsToCode(bullets, opts) code += "\\begin{center}" code += "\\%s[height=%.2f\\textheight,width=0.48\\textwidth,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName1) code += "\\%s[height=%.2f\\textheight,width=0.48\\textwidth,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName2) code += "\\end{center}" return code
def writeSlides(output="output.tex", opts="--compile --copy --dump"): global source opts = utils.parseOptions(opts) if (opts["provenance"]): makeProvenance() source += footer output = output.replace(".pdf", ".tex") output = output.replace( ".py", ".tex") # just so I don't idiotically overwrite the slides!!! SO MAD. fh = open(output, "w") fh.write(source) fh.close() print "[SM] Wrote slides" if (opts["compile"]): # compile twice to get correct slide numbers. latex is dumb. is this the only way? # stat,out = commands.getstatusoutput("pdflatex -interaction=nonstopmode %s && \ # pdflatex -interaction=nonstopmode %s " % (output,output) ) stat, out = commands.getstatusoutput( "pdflatex -interaction=nonstopmode %s " % (output)) if ("Fatal error" in out): print "[SM] ERROR: Tried to compile, but failed. Last few lines of printout below." print "_" * 40 print "\n".join(out.split("\n")[-30:]) return else: print "[SM] Compiled slides to", output.replace(".tex", ".pdf") if (opts["copy"]): stat, out = commands.getstatusoutput( "cp %s ~/public_html/%s/" % (output.replace( ".tex", ".pdf"), "dump" if opts["dump"] else "")) print "[SM] Copied output to uaf-6.t2.ucsd.edu/~%s/%s%s" % ( os.getenv("USER"), "dump/" if opts["dump"] else "", output.replace(".tex", ".pdf")) if (globalOpts["makegui"] and len(objectslides) > 0): utils.makeGUI(objectslides, output.replace(".tex", ".pdf"), os.getcwd())
def addSlidePlotPlot(slideTitle, plotName1, plotName2, drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = "" if (opts["vertical"]): totalSize = 0.84 size1, size2 = 0.5 * totalSize, 0.5 * totalSize if (opts["sizeratio"]): size1, size2 = float(opts["sizeratio"]) * totalSize, ( 1.0 - float(opts["sizeratio"])) * totalSize code = "\\begin{frame}\\frametitle{%s}" % (slideTitle) code += utils.handleStartingOpts(opts) code += """ \\begin{center} \\%s[height=%.2f\\textheight,keepaspectratio]{%s}\\vfill \\%s[height=%.2f\\textheight,keepaspectratio]{%s} \\end{center} """ % (drawType, size1, plotName1, drawType, size2, plotName2) else: totalSize = 0.96 size1, size2 = 0.5 * totalSize, 0.5 * totalSize if (opts["sizeratio"]): size1, size2 = float(opts["sizeratio"]) * totalSize, ( 1.0 - float(opts["sizeratio"])) * totalSize code = "\\begin{frame}\\frametitle{%s}" % (slideTitle) code += utils.handleStartingOpts(opts) code += """ \\begin{center} \\vspace*{-0.035\\textheight}\\%s[width=%.2f\\textwidth,keepaspectratio]{%s} \\hfill \\vspace*{-0.035\\textheight}\\%s[width=%.2f\\textwidth,keepaspectratio]{%s} \\end{center} """ % (drawType, size1, plotName1, drawType, size2, plotName2) return code
def parseGlobalSections(self): # Allow for multiple processes to share the same temp directory by # appending a unique number to the temp directory given. # TODO in general check for paths given by the user whether upper level # TODO parts of the path exists. while not self.tempDirectoryName() or os.path.exists(self.tempDirectoryName()): self.__tempDirectoryName = os.path.join( self.configurationFileParser().get(u"Global", u"tempDirectory"), "%d" % (random.randint(0, 1000000))) os.mkdir(self.tempDirectoryName()) if sys.platform == "win32": # Unset TMP because it results in paths which cannot be used with # pcraster (they contain a ~). See also docs of tempnam. Set TMP to our # own temp directory name. os.putenv("TMP", self.tempDirectoryName()) self.__outputDirectoryName = self.configurationFileParser().get( u"DEFAULT", u"outputDirectory") if not os.path.exists(self.outputDirectoryName()): os.mkdir(self.outputDirectoryName()) if self.configurationFileParser().has_option(u"Global", u"logFile"): self.__logFilename = self.configurationFileParser().get( u"Global", u"logFile") if self.configurationFileParser().has_option(u"Global", u"options"): self.__options = utils.parseOptions(self.configurationFileParser().get( u"Global", u"options")) supportedOptions = [u"SkipPreprocessing"] for option in self.options(): if not option in supportedOptions: utils.raiseUnsupportedOptionException(option, u"Global")
def addSlideTextPlot(slideTitle, bullets, plotName, drawType="includegraphics", opts=""): opts = utils.parseOptions(opts) code = "\\begin{frame}\\frametitle{%s} \n" % (slideTitle) code += utils.handleStartingOpts(opts) if (opts["sidebyside"]): code += "\\begin{columns}\n \\begin{column}{0.5\\textwidth} \n" code += utils.bulletsToCode(bullets, opts) code += "\\end{column}\n \\begin{column}{0.5\\textwidth}" code += " \\begin{center}" code += " \\%s[width=\\textwidth,keepaspectratio]{%s} \n" % ( drawType, plotName) code += " \\end{center}\n \\end{column}\n\\end{columns} \n" elif (opts["plottop"]): code += "\\begin{center}" code += " \\%s[height=%.2f\\textheight,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName) code += "\\end{center}\n" code += utils.bulletsToCode(bullets, opts) else: code += utils.bulletsToCode(bullets, opts) code += "\\begin{center}" if (opts["fithorizontal"]): code += " \\vspace*{%.2f\\textheight}\\%s[width=0.99\\textwidth,keepaspectratio]{%s} \n" \ % (0.9-utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),drawType,plotName) else: code += " \\%s[height=%.2f\\textheight,keepaspectratio]{%s} \n" \ % (drawType, utils.textLinesToPlotHeight(utils.bulletNLines(bullets)),plotName) code += "\\end{center}\n" return code
import subprocess import os import shutil from time import sleep import sys from utils import parseOptions from utils import getOption parseOptions() DEBUG = getOption("debug") WIDTH = str(30) HEIGHT = str(30) DEFAULT_NEG = 1000 DEFAULT_POS = 500 DEFAULT_STAGES = str(20) USE_USER_IMG_NUM = False if getOption("width") != None: WIDTH = getOption("width") if getOption("height") != None: HEIGHT = getOption("height") if getOption("num_stages") != None: DEFAULT_STAGES = getOption("num_stages") if getOption("images") != None: USE_USER_IMG_NUM = True DEFAULT_POS = int(getOption("images")) DEFAULT_NEG = DEFAULT_POS * 2 GEN_FOLDER = "generated" NEGATIVES_FOLDER = "negatives/"
def addSlide(title=None,text=None,p1=None,p2=None,opts="",textobjects=[],arrowobjects=[],boxobjects=[],objects=[]): global source, slideNumber slideNumber += 1 parsedOpts = utils.parseOptions(opts) drawtype = parsedOpts["drawtype"] if parsedOpts["drawtype"] else "includegraphics" bullets = [] if( text ): bullets = text.split("\n") if( not title ): cleanP1 = p1.replace("_","\\_").rsplit(".",1)[0].split("/")[-1] if p1 else "" cleanP2 = p2.replace("_","\\_").rsplit(".",1)[0].split("/")[-1] if p2 else "" if( p1 and not p2 ): title = cleanP1 elif( p2 and not p1 ): title = cleanP2 elif( p1 and p2 ): title = cleanP1 + ", " + cleanP2 else: title = "\\phantom{}" if( p1 and p2 ): if( text ): print "[SM] Adding TextPlotPlot slide #%s" % slideNumber source += addSlideTextPlotPlot(title,bullets,p1,p2,drawType=drawtype,opts=opts) else: print "[SM] Adding PlotPlot slide #%s" % slideNumber source += addSlidePlotPlot(title,p1,p2,drawType=drawtype,opts=opts) elif( p1 ): if( text ): print "[SM] Adding TextPlot slide #%s" % slideNumber source += addSlideTextPlot(title,bullets,p1,drawType=drawtype,opts=opts) else: print "[SM] Adding Plot slide #%s" % slideNumber source += addSlidePlot(title,p1,drawType=drawtype,opts=opts) elif( text ): print "[SM] Adding Text slide #%s" % slideNumber source += addSlideText(title,bullets,opts=opts) elif( title ): print "[SM] Adding Title slide #%s" % slideNumber addSlideTitle(title,opts) else: print "couldn't figure out what you want" drawGrid = False # objects.extend(objs[slideNumber]) objsGUI = [] for objectName in objects: object = {} if objectName in objs: object = objs[objectName] else: print "couldn't find object with id %s. did you define it?" % objectName continue if("grid" in object): drawGrid = True objsGUI.append(object) continue if(object["type"] == "box"): source += utils.getBoxCode(object) if(object["type"] == "circle"): source += utils.getCircleCode(object) if(object["type"] == "arrow"): source += utils.getArrowCode(object) if(object["type"] == "text"): source += utils.getFreetextCode(object) if(object["type"] == "line"): object["opts"] += " --noarrowhead " source += utils.getArrowCode(object) if(object["type"] == "brace"): object["opts"] += " --brace " source += utils.getArrowCode(object) if(drawGrid and globalOpts["makegui"]): objectslides.append( {"slideNumber": slideNumber, "objects": objsGUI} ) print "[SM] Unspecified coordinates for object, will add to GUI" if( drawGrid and globalOpts["makegrid"]): print "[SM] Unspecified coordinates for object, will print out a grid for you" texts, arrows = [], [] ndivs = 20 for i in range(1,ndivs): texts.append( object("text",p1=(0.03,1.0*i/ndivs-0.010),width=0.3, text="\\scalebox{0.7}{%.2f}" % (1.0*i/ndivs), color="red", size=-4, bold=False) ) arrows.append( object("arrow", (0.0,1.0*i/ndivs), (1.0,1.0*i/ndivs), color="grey",opts="--noarrowhead" ) ) texts.append( object("text",p1=(1.0*i/ndivs-0.015,0.01),width=0.3, text="\\scalebox{0.7}{%.2f}" % (1.0*i/ndivs), color="red", size=-4, bold=False) ) arrows.append( object("arrow", (1.0*i/ndivs,0.0), (1.0*i/ndivs,1.0), color="grey",opts="--noarrowhead" ) ) for text in texts: source += utils.getFreetextCode(text) for arrow in arrows: source += utils.getArrowCode(arrow) source += "\\end{frame} \n\n"
def initSlides(me="Nick", themeName="nick", opts=""): global source, commonHeader, theme, themeAlex, themeAlexMod, slideNumber, institute source = "" theme = themeName.lower() opts = utils.parseOptions(opts) slideNumber = 0 print "[SM] Hi", me print "[SM] Using theme:", theme source += commonHeader if (opts["modernfont"]): source += "\\usepackage{helvet} %% only modern font that works on uaf?" if (opts["font"]): # list at http://www.tug.dk/FontCatalogue/sansseriffonts.html # I personally like "--font gillius" source += "\\usepackage{%s}" % opts["font"] if (theme == "nick"): source += themeNick elif (theme == "alex"): source += themeAlex elif (theme == "alexmod"): source += themeAlexMod elif (theme == "madrid"): source += themeMadrid else: print "unsupported theme:", theme if (opts["themecolor"]): themecolor = opts["themecolor"] if "random" in themecolor: themecolor = "%s,%s,%s" % utils.randomColor() print "[SM] Using random theme color: %s" % themecolor source = source.replace( "\\definecolor{thethemecolor}{RGB}{0,0,255}", "\\definecolor{thethemecolor}{RGB}{%s}" % themecolor) if (opts["casual"]): institute = "\\large{%s}" % opts["casual"].replace( "ENDL", "\\\\ \\vspace{0.4cm}") source = source.replace("INSTITUTEHERE", institute) school = "ucsb" fullname = "" if ("Nick" in me): source = source.replace("AUTHORHERE", "Nick Amin") source = source.replace("N. Amin", "\\underline{\\textbf{N. Amin}}") school = "ucsb" elif ("Sicheng" in me): source = source.replace("AUTHORHERE", "Sicheng Wang") source = source.replace("S. Wang", "\\underline{\\textbf{S. Wang}}") school = "ucsb" elif ("Alex" in me): source = source.replace("AUTHORHERE", "Alex George") source = source.replace("A. George", "\\underline{\\textbf{A. George}}") school = "ucsb" elif ("Jason" in me): source = source.replace("AUTHORHERE", "Jason Gran") source = source.replace("J. Gran", "\\underline{\\textbf{J. Gran}}") school = "ucsb" elif ("Giuseppe" in me): source = source.replace("AUTHORHERE", "G. Cerati") source = source.replace("G. Cerati", "\\underline{\\textbf{G. Cerati}}") school = "ucsd" else: print "who are you? add your name to slideMaker." if school == "ucsb": source = source.replace("SCHOOLLOGO", "ucsb.pdf") elif school == "ucsd": source = source.replace("SCHOOLLOGO", "ucsd.png") source = source.replace("GRAPHICSPATHHERE", "".join(["{" + p + "}" for p in graphicspaths])) print "[SM] Initializing slides"
import os, sys, commands import utils from strings import * from collections import defaultdict slideNumber = 0 source = "" theme = "" graphicspaths = [ os.path.dirname(os.path.abspath(__file__)) + "/test/", os.path.dirname(os.path.abspath(__file__)) + "/logos/" ] objectslides = [] globalOpts = utils.parseOptions("") # objs = defaultdict(list) objs = {} def addSlideTitle(title="", opts=""): global source opts = utils.parseOptions(opts) shorttitle = opts["shorttitle"] if opts["shorttitle"] else title titlePageNick = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*}
def addSlide(title=None, text=None, text1=None, text2=None, p1=None, p2=None, p3=None, p4=None, tex=None, opts="", plots=[], objects=[]): global source, slideNumber slideNumber += 1 parsedOpts = utils.parseOptions(opts) drawtype = parsedOpts["drawtype"] if parsedOpts[ "drawtype"] else "includegraphics" if (text1): text = text1 # Compatibility bullets = [] if (text): bullets = text.split("\n") if (text2): bullets2 = text2.split("\n") if (not title): cleanP1 = p1.replace("_", "\\_").rsplit( ".", 1)[0].split("/")[-1] if p1 else "" cleanP2 = p2.replace("_", "\\_").rsplit( ".", 1)[0].split("/")[-1] if p2 else "" if (p1 and not p2): title = cleanP1 elif (p2 and not p1): title = cleanP2 elif (p1 and p2): title = cleanP1 + ", " + cleanP2 else: title = "\\phantom{}" p1 = replaceFixme(p1) p2 = replaceFixme(p2) p3 = replaceFixme(p3) p4 = replaceFixme(p4) plots = replaceFixme(plots) if (not tex): if (p1 and p2): if not text: bullets = [] if (p3 and not p4): print "[SM] Adding TextPlotPlotPlot slide #%s" % slideNumber source += addSlideTextPlotPlotPlot(title, bullets, p1, p2, p3, drawType=drawtype, opts=opts) elif (p3 and p4): print "[SM] Adding TextPlotPlotPlotPlot slide #%s" % slideNumber source += addSlideTextPlotPlotPlotPlot(title, bullets, p1, p2, p3, p4, drawType=drawtype, opts=opts) else: if (text): print "[SM] Adding TextPlotPlot slide #%s" % slideNumber source += addSlideTextPlotPlot(title, bullets, p1, p2, drawType=drawtype, opts=opts) else: print "[SM] Adding PlotPlot slide #%s" % slideNumber source += addSlidePlotPlot(title, p1, p2, drawType=drawtype, opts=opts) elif (len(plots) > 0): print "[SM] Adding TextPlots slide #%s" % slideNumber source += addSlideTextPlots(title, bullets, plots, drawType=drawtype, opts=opts) elif (p1): if (text): print "[SM] Adding TextPlot slide #%s" % slideNumber source += addSlideTextPlot(title, bullets, p1, drawType=drawtype, opts=opts) else: print "[SM] Adding Plot slide #%s" % slideNumber source += addSlidePlot(title, p1, drawType=drawtype, opts=opts) elif (text): if (text2): pass print "[SM] Adding TextText slide #%s" % slideNumber source += addSlideTextText(title, bullets, bullets2, opts=opts) else: print "[SM] Adding Text slide #%s" % slideNumber source += addSlideText(title, bullets, opts=opts) elif (title): print "[SM] Adding Title slide #%s" % slideNumber addSlideTitle(title, opts) else: print "couldn't figure out what you want" else: print "[SM] Adding custom TeX slide #%s" % slideNumber source += addSlideTeX(title, tex, opts=opts) drawGrid = False # objects.extend(objs[slideNumber]) objsGUI = [] for objectName in objects: object = {} if objectName in objs: object = objs[objectName] else: print "couldn't find object with id %s. did you define it?" % objectName continue if ("grid" in object): drawGrid = True objsGUI.append(object) continue if (object["type"] == "box"): source += utils.getBoxCode(object) if (object["type"] == "circle"): source += utils.getCircleCode(object) if (object["type"] == "arrow"): source += utils.getArrowCode(object) if (object["type"] == "text"): source += utils.getFreetextCode(object) if (object["type"] == "line"): object["opts"] += " --noarrowhead " source += utils.getArrowCode(object) if (object["type"] == "brace"): object["opts"] += " --brace " source += utils.getArrowCode(object) if (drawGrid and globalOpts["makegui"]): objectslides.append({"slideNumber": slideNumber, "objects": objsGUI}) print "[SM] Unspecified coordinates for object, will add to GUI" if (drawGrid and globalOpts["makegrid"]): print "[SM] Unspecified coordinates for object, will print out a grid for you" texts, arrows = [], [] ndivs = 20 for i in range(1, ndivs): texts.append( object("text", p1=(0.03, 1.0 * i / ndivs - 0.010), width=0.3, text="\\scalebox{0.7}{%.2f}" % (1.0 * i / ndivs), color="red", size=-4, bold=False)) arrows.append( object("arrow", (0.0, 1.0 * i / ndivs), (1.0, 1.0 * i / ndivs), color="grey", opts="--noarrowhead")) texts.append( object("text", p1=(1.0 * i / ndivs - 0.015, 0.01), width=0.3, text="\\scalebox{0.7}{%.2f}" % (1.0 * i / ndivs), color="red", size=-4, bold=False)) arrows.append( object("arrow", (1.0 * i / ndivs, 0.0), (1.0 * i / ndivs, 1.0), color="grey", opts="--noarrowhead")) for text in texts: source += utils.getFreetextCode(text) for arrow in arrows: source += utils.getArrowCode(arrow) source += "\\end{frame} \n\n"
import os,sys,commands import utils from strings import * from collections import defaultdict slideNumber = 0 source = "" theme = "" graphicspaths = [os.path.dirname(os.path.abspath(__file__))+"/test/", os.path.dirname(os.path.abspath(__file__))+"/logos/"] objectslides = [] globalOpts = utils.parseOptions("") # objs = defaultdict(list) objs = {} def addSlideTitle(title="", opts=""): global source opts = utils.parseOptions(opts) shorttitle = opts["shorttitle"] if opts["shorttitle"] else title titlePageNick = """ \\title[%s]{%s} \\begin{frame} \\titlepage \\begin{textblock*}{2.1cm}(0.12\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{ucsbwave.pdf} \\end{textblock*} \\begin{textblock*}{2.1cm}(0.8\\textwidth,0.8\\textheight) \\includegraphics[height=1.3cm]{cmsbwlogothick.png} \\end{textblock*} """ % (shorttitle,title)