56 contentStarted_(false),
89 bool comp(
int a,
int b ) {
return a > b; } ;
98 out_ <<
"\\documentclass{article}" << endl;
99 out_ <<
"% This figure was generated by the Bio++ Pgf Graphic Device." << endl;
100 out_ <<
"% Althought this file can be compiled 'as is' it may not be displayed correctly, depending on the size of the picture." << endl;
101 out_ <<
"% You may consider copying the pgfpicture environment to your own LaTeX file and play with pgf settings (e.g. the pgfpages module)." << endl;
102 out_ <<
"% You can also use the geometry package, for instance:" << endl;
103 out_ <<
"% \\usepackage[a3paper]{geometry}" << endl;
104 out_ <<
"\\usepackage{pgf}" << endl;
107 if(it->second.substr(0,3) ==
"use")
108 out_ <<
"\\definecolor{" << it->second <<
"}{rgb}{" << it->first[0]/255. <<
"," << it->first[1]/255. <<
"," << it->first[2]/255. <<
"}" << endl;
110 out_ <<
"\\begin{document}" << endl;
117 for(
unsigned int i = 0; i <
layers_.size(); i++)
119 if(i > 0) tmp +=
",";
121 out_ <<
"\\pgfdeclarelayer{" <<
layers_[i] <<
"}" << endl;
123 out_ <<
"\\pgfsetlayers{" << tmp <<
"}" << endl;
127 out_ <<
"\\begin{pgfpicture}" << endl;
128 out_ <<
"\\pgfsetxvec{\\pgfpoint{" <<
getXUnit() <<
"cm}{0cm}}" << endl;
129 out_ <<
"\\pgfsetyvec{\\pgfpoint{0cm}{-" <<
getYUnit() <<
"cm}}" << endl;
131 for(
unsigned int i = 0; i <
content_.size(); i++)
136 out_ <<
"\\end{pgfpicture}" << endl;
137 out_ <<
"\\end{document}" << endl;
142 map<const RGBColor, string>::iterator it =
colorIndex_.find(color);
155 oss <<
"\\pgfsetstrokecolor{" <<
fgColorStr_ <<
"}" << endl;
161 map<const RGBColor, string>::iterator it =
colorIndex_.find(color);
174 oss <<
"\\pgfsetfillcolor{" <<
bgColorStr_ <<
"}" << endl;
182 oss <<
"\\fontfamily{" << font.
getFamily() <<
"}" << endl;
185 oss <<
"\\fontsize{" << font.
getSize() <<
"}{" << font.
getSize() <<
"}" << endl;
186 oss <<
"\\selectfont" << endl;
194 oss <<
"\\pgfsetlinewidth{" <<
x_(size) <<
"}" << endl;
201 if(type == LINE_SOLID)
204 oss <<
"\\pgfsetdash{}{0pt}" << endl;
205 content_.push_back(oss.str());
207 else if(type == LINE_DASHED)
210 oss <<
"\\pgfsetdash{{3mm}{2mm}}{0pt}" << endl;
211 content_.push_back(oss.str());
213 else if(type == LINE_DOTTED)
216 oss <<
"\\pgfsetdash{{" << (x_(getCurrentPointSize())) <<
"}{" << (x_(getCurrentPointSize())) <<
"}}{0pt}" << endl;
217 content_.push_back(oss.str());
225 throw Exception(
"PgfGraphicDevice::setCurrentLayer. A layer is specified after some content has been already added, this would result in a corrupted display.");
231 oss <<
"\\pgfsetstrokecolor{" <<
fgColorStr_ <<
"}" << endl;
232 oss <<
"\\pgfsetfillcolor{" <<
bgColorStr_ <<
"}" << endl;
243 oss <<
"\\pgfpathmoveto{\\pgfpointxy{" << x1 <<
"}{" << y1 <<
"}}" << endl;
244 oss <<
"\\pgfpathlineto{\\pgfpointxy{" << x2 <<
"}{" << y2 <<
"}}" << endl;
245 oss <<
"\\pgfpathclose" << endl;
246 oss <<
"\\pgfusepath{stroke}" << endl;
254 oss <<
"\\pgfpathrectangle{\\pgfpointxy{" << x <<
"}{" << y <<
"}}{\\pgfpointxy{" << width <<
"}{" << height <<
"}}" << endl;
256 oss <<
"\\pgfusepath{stroke,fill}" << endl;
258 oss <<
"\\pgfusepath{stroke}" << endl;
266 oss <<
"\\pgfpathcircle{\\pgfpointxy{" << x <<
"}{" << y <<
"}}{" << radius <<
"}" << endl;
268 oss <<
"\\pgfusepath{stroke,fill}" << endl;
270 oss <<
"\\pgfusepath{stroke}" << endl;
278 if(vpos == TEXT_VERTICAL_BOTTOM)
280 else if(vpos == TEXT_VERTICAL_TOP)
282 else if(vpos == TEXT_VERTICAL_CENTER)
284 else throw UnvalidFlagException(
"PgfGraphicDevice::drawText. Invalid vertical alignment option.");
285 if(hpos == TEXT_HORIZONTAL_LEFT)
287 else if(hpos == TEXT_HORIZONTAL_RIGHT)
289 else if(hpos == TEXT_HORIZONTAL_CENTER)
291 else throw UnvalidFlagException(
"PgfGraphicDevice::drawText. Invalid horizontal alignment option.");
294 oss <<
"\\pgftransformrotate{" << angle <<
"}" << endl;
295 oss <<
"\\pgftext[" << anchor <<
",at=\\pgfpointxy{" << x <<
"}{" << y <<
"}]{\\textcolor{" << fgColorStr_ <<
"}" << text <<
"}" << endl;
296 content_.push_back(oss.str());
297 contentStarted_ =
true;