16 #define FSCX "Resolution (A-1)"
17 #define FSCY "Correlation Coefficient"
35 cout <<
"# Reading XML file: " << filename << endl;
37 xmlDocPtr doc = xmlParseFile(filename.
c_str());
41 xmlNodePtr fsc_node = xmlDocGetRootElement(doc);
44 if ( fsc_node == NULL ) {
50 if ( xmlStrcmp(fsc_node->name, (
const xmlChar *)
"fsc") ) {
51 cerr <<
"Error: The document " << filename <<
" is not an FSC curve!" << endl;
56 int i, ncol(2), nrow(0);
58 for ( nrow=0, coor_node = fsc_node->xmlChildrenNode; coor_node; coor_node = coor_node->next )
59 if ( !xmlStrcmp(coor_node->name, BAD_CAST
"coordinate") ) nrow++;
61 Bstring title = (
char *) xmlGetProp(fsc_node, BAD_CAST
"title");
67 plot->
page(0).
column(0).
label((
char *) xmlGetProp(fsc_node, BAD_CAST
"xaxis"));
68 plot->
page(0).
column(1).
label((
char *) xmlGetProp(fsc_node, BAD_CAST
"yaxis"));
81 for ( i=0, coor_node = fsc_node->xmlChildrenNode; coor_node; coor_node = coor_node->next ) {
82 if ( !xmlStrcmp(coor_node->name, BAD_CAST
"coordinate") ) {
124 long n, i, j, k, cx, cy, nrows = plot->
rows();
130 xmlNodePtr coor_node;
132 for ( n=0; n<plot->
pages(); n++ ) {
135 cout <<
"# Writing an XML file: " << filename1 << endl << endl;
138 doc = xmlNewDoc(BAD_CAST XML_DEFAULT_VERSION);
139 node = xmlNewDocPI(doc, BAD_CAST
"xml-stylesheet",
140 BAD_CAST
"href=\"Bsoft_micrograph.xsl\" type=\"text/xsl\"");
141 xmlDocSetRootElement(doc, node);
142 fsc_node = xmlNewNode(NULL, BAD_CAST
"fsc");
143 xmlAddSibling(node, fsc_node);
144 xmlNewProp(fsc_node, BAD_CAST
"title", BAD_CAST
"FSC Plot");
145 xmlNewProp(fsc_node, BAD_CAST
"xaxis", BAD_CAST
FSCX);
146 xmlNewProp(fsc_node, BAD_CAST
"yaxis", BAD_CAST
FSCY);
147 for ( i=cx*nrows, j=cy*nrows, k=0; k<nrows; i++, j++, k++ ) {
148 coor_node = xmlNewChild(fsc_node, NULL, BAD_CAST
"coordinate", NULL);
152 xmlSaveFormatFile(filename1.c_str(), doc, 1);
170 cout <<
"# Reading XML file: " << filename << endl;
173 fx.open(filename.
c_str());
174 if ( fx.fail() )
return NULL;
176 int i, j, ncol(2), nrow(0);
180 while ( !fx.eof() ) {
182 if ( strstr(aline,
"<coordinate>") ) nrow++;
205 fx.seekg(0, ios::beg);
207 for ( i=0, j=nrow; !fx.eof(); ) {
209 if ( sscanf(aline,
"<x>%f</x>", &x) ) (*plot)[i] = x;
210 if ( sscanf(aline,
"<y>%f</y>", &y) ) { (*plot)[j] = y; i++; j++; }
220 long n, i, j, k, cx, cy, nrows = plot->
rows();
224 for ( n=0; n<plot->
pages(); n++ ) {
228 fx.open(filename1.
c_str());
229 fx <<
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
230 fx <<
"<fsc title=\"FSC Plot\" xaxis=\"" <<
FSCX <<
"\" yaxis=\"" <<
FSCY <<
"\">" << endl;
231 for ( i=cx*nrows, j=cy*nrows, k=0; k<nrows; i++, j++, k++ ) {
232 fx <<
"<coordinate>" << endl;
233 fx <<
"\t<x>" << (*plot)[i] <<
"</x>" << endl;
234 fx <<
"\t<y>" << (*plot)[j] <<
"</y>" << endl;
235 fx <<
"</coordinate>" << endl;
237 fx <<
"</fsc>" << endl;