My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Enumerations | Functions
plantuml.h File Reference

Go to the source code of this file.

Enumerations

enum  PlantUMLOutputFormat { PUML_BITMAP, PUML_EPS, PUML_SVG }
 

Functions

QCString writePlantUMLSource (const QCString &outDir, const QCString &fileName, const QCString &content)
 
void generatePlantUMLOutput (const char *baseName, const char *outDir, PlantUMLOutputFormat format)
 

Enumeration Type Documentation

Plant UML output image formats

Enumerator
PUML_BITMAP 
PUML_EPS 
PUML_SVG 

Definition at line 22 of file plantuml.h.

Function Documentation

void generatePlantUMLOutput ( const char *  baseName,
const char *  outDir,
PlantUMLOutputFormat  format 
)

Convert a PlantUML file to an image.

Parameters
[in]baseNamethe name of the generated file (as returned by writePlantUMLSource())
[in]outDirthe directory to write the resulting image into.
[in]formatthe image format to generate.

Definition at line 54 of file plantuml.cpp.

References Config_getBool, Config_getList, Config_getString, err(), maxCmdLine, msg(), portable_pathListSeparator(), portable_system(), portable_sysTimerStart(), portable_sysTimerStop(), PUML_BITMAP, PUML_EPS, and PUML_SVG.

Referenced by FlowChart::printUmlTree(), HtmlDocVisitor::writePlantUMLFile(), DocbookDocVisitor::writePlantUMLFile(), RTFDocVisitor::writePlantUMLFile(), and LatexDocVisitor::writePlantUMLFile().

{
static QCString plantumlJarPath = Config_getString(PLANTUML_JAR_PATH);
QCString pumlExe = "java";
QCString pumlArgs = "";
QStrList &pumlIncludePathList = Config_getList(PLANTUML_INCLUDE_PATH);
char *s=pumlIncludePathList.first();
if (s)
{
pumlArgs += "-Dplantuml.include.path=\"";
pumlArgs += s;
s = pumlIncludePathList.next();
}
while (s)
{
pumlArgs += s;
s = pumlIncludePathList.next();
}
if (pumlIncludePathList.first()) pumlArgs += "\" ";
pumlArgs += "-Djava.awt.headless=true -jar \""+plantumlJarPath+"plantuml.jar\" ";
pumlArgs+="-o \"";
pumlArgs+=outDir;
pumlArgs+="\" ";
QCString extension;
switch (format)
{
pumlArgs+="-tpng";
extension=".png";
break;
case PUML_EPS:
pumlArgs+="-teps";
extension=".eps";
break;
case PUML_SVG:
pumlArgs+="-tsvg";
extension=".svg";
break;
}
pumlArgs+=" \"";
pumlArgs+=baseName;
pumlArgs+=".pu\" ";
pumlArgs+="-charset UTF-8 ";
int exitCode;
//printf("*** running: %s %s outDir:%s %s\n",pumlExe.data(),pumlArgs.data(),outDir,outFile);
msg("Running PlantUML on generated file %s.pu\n",baseName);
if ((exitCode=portable_system(pumlExe,pumlArgs,TRUE))!=0)
{
err("Problems running PlantUML. Verify that the command 'java -jar \"%splantuml.jar\" -h' works from the command line. Exit code: %d\n",
plantumlJarPath.data(),exitCode);
}
else if (Config_getBool(DOT_CLEANUP))
{
QFile(QCString(baseName)+".pu").remove();
}
if ( (format==PUML_EPS) && (Config_getBool(USE_PDFLATEX)) )
{
QCString epstopdfArgs(maxCmdLine);
epstopdfArgs.sprintf("\"%s.eps\" --outfile=\"%s.pdf\"",baseName,baseName);
if ((exitCode=portable_system("epstopdf",epstopdfArgs))!=0)
{
err("Problems running epstopdf. Check your TeX installation! Exit code: %d\n",exitCode);
}
}
}
QCString writePlantUMLSource ( const QCString &  outDir,
const QCString &  fileName,
const QCString &  content 
)

Write a PlantUML compatible file.

Parameters
[in]outDirthe output directory to write the file to.
[in]fileNamethe name of the file. If empty a name will be chosen automatically.
[in]contentthe contents of the PlantUML file.
Returns
The name of the generated file.

Definition at line 25 of file plantuml.cpp.

References err().

Referenced by FlowChart::printUmlTree(), DocbookDocVisitor::visit(), RTFDocVisitor::visit(), LatexDocVisitor::visit(), and HtmlDocVisitor::visit().

{
QCString baseName(4096);
static int umlindex=1;
if (fileName.isEmpty()) // generate name
{
baseName = outDir+"/inline_umlgraph_"+QCString().setNum(umlindex++);
}
else // user specified name
{
baseName = fileName;
int i=baseName.findRev('.');
if (i!=-1) baseName = baseName.left(i);
baseName.prepend(outDir+"/");
}
QFile file(baseName+".pu");
if (!file.open(IO_WriteOnly))
{
err("Could not open file %s for writing\n",baseName.data());
}
QCString text = "@startuml\n";
text+=content;
text+="@enduml\n";
file.writeBlock( text, text.length() );
file.close();
return baseName;
}