Skip to content

Commit

Permalink
core: fix issue #2 with CDXML saver
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderSavelyev committed Jun 22, 2015
1 parent b8dad51 commit 19db466
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions molecule/src/molecule_cdxml_saver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,22 @@ void MoleculeCdxmlSaver::saveMoleculeFragment (Molecule &mol, const Vec2f &offse
s->SetAttribute("size", 10);
s->SetAttribute("face", 96);

TiXmlText * txt = new TiXmlText("A");
out.clear();
out.printf("A");
/*
* Skip charge since Chemdraw is pure. May be in future it will be fixed by Chemdraw
*/
/*if (charge != 0) {
if (charge > 0) {
out.printf("+%d", charge);
}
else {
out.printf("-%d", charge);
}
}*/
buf.push(0);

TiXmlText * txt = new TiXmlText(buf.ptr());
s->LinkEndChild(txt);
}
else if (mol.isPseudoAtom(i))
Expand All @@ -362,7 +377,7 @@ void MoleculeCdxmlSaver::saveMoleculeFragment (Molecule &mol, const Vec2f &offse

QS_DEF(Array<char>, buf);
ArrayOutput out(buf);
out.printf(buf.ptr(), "%f %f", pos.x, -pos.y);
out.printf("%f %f", pos.x, -pos.y);
buf.push(0);
t->SetAttribute("p", buf.ptr());
t->SetAttribute("LabelJustification", "Left");
Expand All @@ -373,7 +388,22 @@ void MoleculeCdxmlSaver::saveMoleculeFragment (Molecule &mol, const Vec2f &offse
s->SetAttribute("size", 10);
s->SetAttribute("face", 96);

TiXmlText * txt = new TiXmlText(mol.getPseudoAtom(i));
out.clear();

out.printf("%s", mol.getPseudoAtom(i));
/*
* Skip charge since Chemdraw is pure. May be in future it will be fixed by Chemdraw
*/
/*if (charge != 0) {
if (charge > 0) {
out.printf("+%d", charge);
}
else {
out.printf("-%d", charge);
}
}*/
buf.push(0);
TiXmlText * txt = new TiXmlText(buf.ptr());
s->LinkEndChild(txt);
}
}
Expand Down Expand Up @@ -488,7 +518,11 @@ void MoleculeCdxmlSaver::addCustomText(const Vec2f &pos, const char *alignment,
buf.push(0);
t->SetAttribute("p", buf.ptr());
t->SetAttribute("Justification", alignment);
t->SetAttribute("LineHeight", sprintf(buf.ptr(), "%f", line_height));

out.clear();
out.printf("%f", line_height);
buf.push(0);
t->SetAttribute("LineHeight", buf.ptr());

TiXmlUnknown * s = new TiXmlUnknown();
buf.readString(text, false);
Expand All @@ -499,7 +533,6 @@ void MoleculeCdxmlSaver::addCustomText(const Vec2f &pos, const char *alignment,
s->SetValue(buf.ptr());
t->LinkEndChild(s);
}
//buf.remove(0);

}

Expand Down

0 comments on commit 19db466

Please sign in to comment.