Greg,

I figured out what the problem is:

getStringSize() calculates the pixel height/width of a given atom label.
For labels such as NH3+ the argument this function is getting is
NH<sub>3</sub><sup>+</sup>

which makes for a very long sting, which throws off the scale calculation.
I am not sure why it works correctly with the drawers other than SVG but
for wxWidgets I need to clean from the label  <sub>, <sup>, </sub>, and
</sup>
before computing the string width.

Hope this helps to someone who might have the same problem.

Best regards,
Igor




On Fri, Sep 8, 2017 at 8:29 AM, Igor Filippov <igor.v.filip...@gmail.com>
wrote:

> Great - thanks, I'll try it!
>
> Igor
>
> On Fri, Sep 8, 2017 at 8:27 AM, Greg Landrum <greg.land...@gmail.com>
> wrote:
>
>>
>> On Fri, Sep 8, 2017 at 2:10 PM, Igor Filippov <igor.v.filip...@gmail.com>
>> wrote:
>>
>>>
>>>>
>>>> Could it be that you didn't generate coordinates for the molecule?
>>>>
>>>> The result is the same for me whether I load the molecule from an SD
>>> file with coordinates, or generate 2D or 3D coordinates on the fly.
>>> Does it display correctly for you?
>>>
>>
>> Yeah, This snippet:
>>
>> In [21]: m = Chem.MolFromSmiles('NC(=O)C(N)CCCC[NH3+]')
>>
>> In [22]: nm = Draw.PrepareMolForDrawing(m)
>>
>> In [23]: d = Draw.MolDraw2DCairo(200,200)
>>
>> In [24]: d.DrawMolecule(nm)
>>
>> In [25]: d.FinishDrawing()
>>
>> In [26]: open('blah.png','wb+').write(d.GetDrawingText())
>> Out[26]: 2730
>>
>>
>> Produces the png file that's attached.
>>
>>
>>> BTW: rdMolDraw2D.PrepareMolForDrawing() is a useful function to know
>>>> about.
>>>>
>>> I am doing it from c++, is there an equivalent there?
>>>
>>
>> Sure, here's some testing code that uses it:
>> https://github.com/rdkit/rdkit/blob/9af90524a41825b67ffb19cd
>> bff9b363d5a7ca7e/Code/GraphMol/MolDraw2D/test1.cpp#L987
>>
>> There are a bunch of other examples in that file too.
>>
>> -greg
>>
>>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Rdkit-devel mailing list
Rdkit-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rdkit-devel

Reply via email to