Re: [Rdkit-discuss] rdMolDraw2D drawing code
Open-Source Cheminformatics and Machine Learning
Brought to you by:
glandrum
|
From: Greg L. <gre...@gm...> - 2016-09-05 08:47:56
|
Dave's right about the font size: it's expressed in whatever coordinates the molecule is being drawn in. Cross-platform font handling is tough. Cross-platform, cross-toolkit font handling is even tougher. What's currently there seems to be an quasi-workable solution. I suspect the other part of Dmitri's question is about the way bonds are shortened so that they don't draw all the way through the atom labels. This is handled by a function in MolDraw2D that attempts to take into account the font size. It doesn't always succeed (see the comments above about font handling). It's easy enough to add an option that allows you to adjust the amount of padding that's used in that code. Here's the github issue: https://github.com/rdkit/rdkit/issues/1056 -greg On Mon, Sep 5, 2016 at 9:57 AM, David Cosgrove <dav...@gm...> wrote: > HI Dmitri, > > Sorry for the delay replying. I assume that by 'add padding' you mean that > the code that generates the 2D drawing coordinates should take account of > the size of the labels and would, from your example, maybe open out the > C9-O23-C14 bond a bit so that O21 and O24 are further apart? If so, then I > can duck that one cheerfully as it's not part of the MolDraw2D code. The 2D > coordinates are generated in RDDepictor - MolDraw2D just uses the results > from that. Having just had a peer at $RDBASE/GraphMol/Depictor/Depictor.h, > it would seem as though adding a padding as you suggest might not be > straightforward, but I guess it might be possible to alter the distance > matrix that is being embedded in 2D to take account of atom label sizes. > The joy of open source projects is of course that you have the opportunity > to change things if you don't like how they're done at present. Maybe > something to think about at the UGM hackathon day? > > As you say, your best bet in the short term is probably to adjust the font > size in the drawing. MolDraw2D.h says that the font sizes are given "in > molecule coordinate units. That's probably Angstrom for RDKit" which in > reality means it's relative to a C-C bond in benzene of 1.5 units. This is > then changed internally to a value appropriate for the drawing engine that > is being used in a particular instance. If you can see a sensible place to > put this information in the documentation, feel free to send a changed > version to Greg for inclusion in the next release. I am struggling to find > any such documentation myself, and maybe that was your point ;-). > > Cheers, > Dave > > > On Fri, Sep 2, 2016 at 9:07 PM, Dimitri Maziuk <dm...@bm...> > wrote: > >> Hi all, >> >> I finally got a round tuit for playing with the drawing code and I like >> it -- great job, thank you Greg and Dave and everyone who contributed. >> >> One question though: is it possible to add padding around atom labels? >> Or use some other trick to make the attached look less crowded? (Yes, I >> do want all Hs and all atom labels with numbers.) >> >> The best I can come up with is reduce the font size a little, that works >> fine. I think it'd be nice if the fine manual for MolDraw2D said what >> the units used by FontSize()/SetFontSize() are. >> >> So, any better ideas than just slightly smaller labels? >> >> TIA >> -- >> Dimitri Maziuk >> Programmer/sysadmin >> BioMagResBank, UW-Madison -- http://www.bmrb.wisc.edu >> >> ------------------------------------------------------------ >> ------------------ >> >> _______________________________________________ >> Rdkit-discuss mailing list >> Rdk...@li... >> https://lists.sourceforge.net/lists/listinfo/rdkit-discuss >> >> > > ------------------------------------------------------------ > ------------------ > > _______________________________________________ > Rdkit-discuss mailing list > Rdk...@li... > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > > |