Commit Graph

77 Commits

Author SHA1 Message Date
David Cosgrove
8d1eb53d4c Option to draw all bonds in symbolColour. (#9304) 2026-05-29 05:53:20 +02:00
David Cosgrove
41fa15f4a1 Fix layout of reaction components in reaction drawing. (#9302)
* Fix layout of reaction components in reaction drawing.

* <sigh>

---------

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2026-05-29 05:52:18 +02:00
Chris Von Bargen
d2f44719ae Add getSGroupDataLabels() to MolDraw2D_detail namespace (#9189)
Adds a new function MolDraw2D_detail::getSGroupDataLabels() that returns
the text and molecule-coordinate positions of DAT SGroup labels, using
the same placement logic as the drawing code. This allows external
renderers to display SGroup labels consistently with RDKit's placement.

Refactors DrawMol::extractSGroupData() to call getSGroupDataLabels()
internally, eliminating the duplicate FIELDDISP parsing and position
computation logic.

Closes #7829

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-30 14:19:56 +02:00
Brandon Novy
0552d94d5e MolDraw2D: configurable legend position and vertical side legends (Issue #9023) (#9183)
* Configurable legend position (Top/Left/Right/Bottom) and vertical text (GitHub #9023)

- Add LegendPosition enum and legendPosition, legendVerticalText to MolDrawOptions
- Support legend at Top, Left, Right, Bottom; vertical text for Left/Right
- Python: MolDrawOptions.legendPosition, .legendVerticalText; LegendPosition enum
- Python: MolToSVG() wrapper with legend/drawOptions; doc updates for MolToImage
- JSON: legendPosition (string), legendVerticalText (bool) in draw options
- C++ and Python tests; release note and Cartridge.md docs

* MolDraw2D: legend gutter for horizontal side legends; vertical side height fit

- Reserve horizontal gap between molecule and left/right horizontal legends
  (scale mol to molWidth-gutter, align toward legend strip).
- Position horizontal side legend by measured text width from partition edge.
- Vertical side legends: iterative scale so n*max_h+(n-1)*gap fits panel.
- Catch: long vertical side legend section.

* Update legend-position tests and review-driven cleanup

Use enum/default wording for legendPosition docs, move the lightweight Python test to Wrap, add regex-based placement checks (including horizontal side and vertical stacking), and refactor extractLegend helpers per style guidance.

* Fix MolDraw2D legend edge cases

* MolDraw2D: review follow-up (legend tests, bounds, DRY Top/Bottom)

* Update no-FT legend test coords

* Address PR review: document constants, remove release-note text, and simplify extra-padding logic
2026-04-30 14:18:05 +02:00
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +02:00
Paolo Tosco
805294c27f - move MolDrawOptions JSON parsing code to a separate compilation unit (#8783)
- implement drawingExtentsInclude MolDrawOption taking as parameter DrawElement enum values
- add unit tests for drawingExtentsInclude option (C++, Python, CFFI)

Co-authored-by: ptosco <paolo.tosco@novartis.com>
2025-09-23 09:27:13 +02:00
paconius
1fe07a5eb7 Add option to draw all CIP codes in DrawMol.cpp (#8609)
* enable showAllCIPCodes in DrawMol code

* Made consistent with old behavior + add test

* Added python test

* Fixed FREETYPE=OFF tests

* Fixed FREETYPE=OFF tests

* Adjusted pytest

* Enabled JSON drawer option setting + new JSON test

* update JS docs
2025-07-24 16:46:15 +02:00
David Cosgrove
81cc5bc704 Option for standard atom colours with highlighting (#8294)
* Option to use standard atom colours under highlights.

* Update hash codes for catch_tests.cpp.

* Update hash codes for test1.cpp and rxn_test1.cpp.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-02-24 17:46:24 +01:00
Greg Landrum
7311390005 MolDraw2D: add separate colors for atom and bond annotations (#8249) 2025-02-15 08:28:00 +01:00
David Cosgrove
79ec783cab Add option to omit brackets when drawing query atoms. (#8212)
* Fix bond smoothing - apply atom index offset to products.
Update Hash codes.
Tweak side_by_side_images.py.

* Added hash code for new file.  Doh!

* Option to remove brackets from atom lists.

* Python wrapper.

* Change option name after review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2025-01-27 16:59:29 +01:00
David Cosgrove
451e57f0ff Fix bond join smoothing in images of reaction products (#8210)
* Fix bond smoothing - apply atom index offset to products.
Update Hash codes.
Tweak side_by_side_images.py.

* Added hash code for new file.  Doh!

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-01-27 12:44:50 +01:00
David Cosgrove
4f224cee64 Move creation of 2D coords to before markUnspecifiedStereoAsUnknown. (#8179)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-01-23 06:03:20 +01:00
Paolo Tosco
4431fb708c avoid that map::at() throws an exception in case atomColourPalette includes neither 6 nor -1 (#8085)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2024-12-12 06:13:52 +01:00
David Cosgrove
578b56a7c5 Resolve clashing atom labels in 2D drawing (#8074)
* Move atom labels round if they clash.

* Tidy.

* Re-work orientation logic.
Remove virtual fns from AtomSymbol.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-12-11 09:25:17 +01:00
Ricardo Rodriguez
ff93b2919f look at y if x is very small (#8011) 2024-11-17 06:22:25 +01:00
David Cosgrove
5484738f3e Highlighted hetero atoms disappear (#7672)
* Make atom symbols black if atom is highlighted.

* Only do it for circle and continuous highlights.

* A lot of hash codes changed.

* Check hash code for new file.

* Change the highlighted atom to the same as carbon to accommodate dark mode, for example.

* Change the highlighted atom to the same as carbon to accommodate dark mode, for example.  But get the logic right this time.

* Safer map lookup.

* Stackoverflow says this is better for >= C++17 as only one lookup.
2024-09-16 15:14:14 +02:00
David Cosgrove
9aa77acd1f Fix drawing of 2 colour wedges. (#7760)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-08-28 05:58:18 +02:00
David Cosgrove
4c8b27717a Don't do the fancy merging of solid wedges and bond lines for triple … (#7738)
* Don't do the fancy merging of solid wedges and bond lines for triple bonds.

* Changes after review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-08-23 17:14:15 +02:00
David Cosgrove
58d7254c1d Add atom map number to complex query atom symbol. (#7571)
* Add atom map number to complex query atom symbol.

* Changes after review.
2024-07-04 06:45:19 +02:00
Paolo Tosco
e908c482cc fix #7543 (#7546)
Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-06-24 04:51:42 +02:00
Paolo Tosco
50aea5cf62 Fix issues arising from useMolBlockWedging and the new atropisomer kekulization code (#7540)
* - When depictions are made using the useMolBlockWedging flag, make sure that kekulization is done after original wedging has been applied to reduce the odds that bond wedges are placed on double bonds
- Refactored MinimalLib code to avoid code duplication
- get_molblock() should reapplyMolBlockWedging on a copy of the passed molecule rather than on the original
- Added unit tests

* Update Code/MinimalLib/jswrapper.cpp

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>

---------

Co-authored-by: ptosco <paolo.tosco@novartis.com>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2024-06-20 19:32:41 +02:00
Greg Landrum
8c27805fa3 Allow wedged double and aromatic bonds (#7495)
* support wedging in double and aromatic bonds

This is a first pass and the testing isn't really there.

* add expected test results (from windows...)
switch to not using freetype for the tests

* response to review
2024-06-07 05:09:33 +02:00
Greg Landrum
ba5f43fa6f Fixes #7438 (#7474)
This moves the function into the Chirality namespace.
2024-05-31 14:41:22 +02:00
David Cosgrove
3d550bc1db Fixes problem from discussion 7317 (#7345)
* Extend double bond far enough.

* Oops.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-04-11 18:31:48 +02:00
Greg Landrum
9367e207d5 remove some warnings with -Wextra (#7339) 2024-04-11 11:01:59 +02:00
Greg Landrum
716b38a2d8 Fixes #7140 (#7150)
* Fixes #7140

deprecates the old version and creates a new one in Chirality.h
adds it to the python wrappers

* changes in response to review

* backup

* support custom labels with templates
2024-02-12 15:50:02 +01:00
David Cosgrove
6b916c3e48 Fixes 7036 - middle line of triple bond meeting wedge (#7046)
* Before making a wedged bond meet a single bond, check if they're co-linear and skip if so.

* Write the file before the test so we can still look at it if the test fails.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2024-01-16 06:27:50 +01:00
tadhurst-cdd
d5d4d194ec atropisomer handling added (#6903)
* atropisomer handling added

* fixed non-used variables,  linking directives

* BOOST LIB start/stop fixes, linking fix

* Fixes for RDKIT CI errors

* minimalLib fix

* changed vector<enum> for java builds

* check for extra chars in CIP labeling

* removed wrong deprecated message

* fix ostrstream output error?

* restored _ChiralAtomRank to lowercase first letter

* changes for merged master

* Fixed catch label for new Catch package

* update expected psql results

* get swig wrappers building

* restore MolFileStereochem to FileParsers

* fix java wrapper for reapplyMolBlockWedging

* some suggestions

* move a couple functions out of Bond

* Merge branch 'master' into pr/atropisomers2

* merged master

* Renamed setStereoanyFromSquiggleBond

* atropisomers in cdxml, rationalize atrop wedging, stereoGroups in drawMol

* fix for CI build

* attempt to fix java build in CI

* attempt to fix java build in CI #2

* New routine to remove non-explicit  3D-geneated chirality

* changed to use pair for atrop atoms and related bonds

* Changes as per PR reviews

* PR review respnses

* PR review reponse - more

* Fix merge from master

* fixing java ci after merge

* Updated the help doc for atripisomers

* update the atropisomer docs

* improve the images

* add the source CXSMILES

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-12-22 04:58:18 +01:00
David Cosgrove
fbd548ecdd Github6968 (#6979)
* Fix bond highlighting of linear system.

* Hash code & un-comment out code.

* Response to review.
2023-12-18 06:25:23 +01:00
Greg Landrum
036f75bca3 Removed some code duplication between Depictor.cpp and common.h (#6799)
* Revert "Revert "Removed some code duplication between Depictor.cpp and common.h (#6368)" (#6797)"

This reverts commit 824616c5b9.

* security blanket: add back tests of the current usage pattern

* - fixed bug in get_sss_json() (#6806)

- added unit test for the above

Co-authored-by: ptosco <paolo.tosco@novartis.com>

---------

Co-authored-by: Paolo Tosco <paolo.tosco.mail@gmail.com>
Co-authored-by: ptosco <paolo.tosco@novartis.com>
2023-10-18 04:04:45 +02:00
Greg Landrum
824616c5b9 Revert "Removed some code duplication between Depictor.cpp and common.h (#6368)" (#6797)
This reverts commit ddfe708b37.
2023-10-11 06:42:27 +02:00
Paolo Tosco
ddfe708b37 Removed some code duplication between Depictor.cpp and common.h (#6368)
* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true)   to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications

* Fix chirality handling when the chiral atom is the first one in a SMARTS (#6730)

* Set _SmilesStart when parsing SMARTS.

* SmartsWriter should also invert first atoms, like SMILES.

* Update test cases now these SMILES match themselves as SMARTS.

* rerun bison

* cleanup a possible repeated define

* When an atom moves from the first to second position winding should flip in SMARTS (i.e. same as SMILES).

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>

* Some small cleanups from the UGM Hackathon (#6744)

* move definition of a couple global constants from a .h to a .cpp

* careful removal of some redundant atom PRECONDITIONS

* careful remove of some redundant ROMol PRECONDITIONS
a bit of additional cleanup

* optimization masquerading as modernization

* some more tidying

* a bit more atom cleanup

* change in response to review

* Fixes #6756 (#6780)

* update release notes and cmakelists for beta (#6788)

* move problematic functions to Chirality namespace

* - implemented alignOnly mode into RDDepict::generateDepictionMatching2DStructure()
- the allowRGroups option now also supports potentially missing R groups (i.e., R groups that do not match any atom, such as those connected to generic aromatic atoms)
- added the adjustMolBlockWedging parameter (which defaults to true)   to invert/clear molblock wedging information as appropriate
- added unit tests for the above new features
- added RDDepict::generateDepictionMatching2DStructure() overloads taking RDDepict::ConstrainedDepictionParams parameter for convenience
- removed some redundant RDDepict:: namespace specifications

* move problematic functions to Chirality namespace

* added missing dependency

* let's check what is going wrong

* CoordGen tests should not run if CoordGen support is not available in the build

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
Co-authored-by: John Mayfield <john@nextmovesoftware.com>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2023-10-11 06:41:37 +02:00
Greg Landrum
83cf752eb0 extract continuous lines from the conrec code (#6676) 2023-09-15 09:00:26 +02:00
David Cosgrove
9249ca5cc8 Make reaction drawings deal with padding properly. (#6686)
* Make reaction drawings deal with padding properly.

* Move large lambdas into anonymous namespace.
Correct totWidth after scaling plusWidth.

* Update some hashcodes.

* Take out debugging setting.  Bugger.

* Padding on height as well.

* Hash codes.

* Delay padding use in flexiCanvas.

* More centring.

* Light grey background in side_by_side table.

* Tweak agents layout for testReactionCoords.

* Fully ignore missing reagents and products.

* Hash codes.

* Const references.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-09-09 06:46:35 +02:00
Ric
9737b10143 fix some more leaks (#6684)
* fix some more leaks

* review comments
2023-09-04 06:38:01 +02:00
David Cosgrove
6f70dc2a7d Github6400 (#6553)
* Fix bug where large padding gave a legend font size of 0.
The padding is now implemented by making a smaller, offset drawing area within the width_ and height_, dimensions drawWidth_, drawHeight_.  The previous drawHeight_ has been replaced by molHeight_.

* Update test results.

* Update hash codes.

* Update test results.

* Update test results for no freetype.

* Update hash codes for no freetype.

* Update hash codes for freetype.

* Update hash codes for no freetype.

* Update hash codes for freetype.

* Update expected test results.

* Update hash codes.

* Fix contour plots not being lined up with atoms.

* Fix shrinkToFit.

* Update expected test result.

* Fix typo in test name.

* Update expected test result.

* Update expected test result.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-08-30 12:35:33 +02:00
David Cosgrove
64550f0a26 Check for very close atoms and act accordingly. (#6583)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-08-03 18:53:00 +02:00
David Cosgrove
a8d9e6de9c Don't call bondNonRing with a 2-label double bond. (#6571) 2023-07-23 06:48:40 +02:00
David Cosgrove
1e16a86648 Fix clash of molecule note with molecule. (Github 6397). (#6444)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-06-17 06:00:27 +02:00
Paolo Tosco
a11a9ce607 fixes #6416 (#6425)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-06-02 09:33:07 +02:00
Paolo Tosco
fb878bdbe4 exposed queryColour in MolDrawOptions (#6282)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-04-14 04:52:59 +02:00
Greg Landrum
cde573d621 add features to allow drawing molecules in arbitrary positions on a large canvas (#6210)
* drawMolecule and drawMolecules should not be virtual

* clarity

* add getMolSize() and flexiMode

* changes in response to review
2023-03-22 17:27:10 +01:00
David Cosgrove
1f0a35f732 Better name for areBondsLinear. (#6196)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-03-15 06:05:36 +01:00
David Cosgrove
187814e77b Uncross accidentally crossed bonds. (#6187)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-03-14 06:39:58 +01:00
David Cosgrove
8d859469c5 Fix drawing of Aminosulfimine Take 2 (#6169)
* Test for Github6160

* Basic fix.  Problem caused by 4 coordinate sulfur.

* Get the test right.

* Fix truncation of double bonds to atom symbols.

* Fix double bond lines if both ends have atomic symbol.

* Tidy.
Add hash codes.

* Response to review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-03-06 17:37:29 +01:00
David Cosgrove
cf52e537cb Fix small ACS1996 drawing being cropped. (#6114) 2023-02-20 23:08:45 +01:00
Paolo Tosco
53800c616c Enable optional visualization of complex query atoms in a more compact form (#6056)
* enable optional visualization of complex query atoms in a more compact form

* disable alpha channel support on legacy browsers

* - changes in response to review
- added metal queries
- fixed a docstring

* fix Windows build

* gave up and tested indirectly as I really do not want to export internal functions

---------

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-02-16 12:34:05 +01:00
Paolo Tosco
90c7d3c5d2 fixes #6054 (#6055)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-02-05 08:14:56 +01:00
David Cosgrove
e4ece1b0f7 Bad double bond in linear group (#6028)
* Adapt allene drawing code to cope with other linear groups.

* Remove stray debugging write.

* Over-eager tidying remove key aspect of the fix.  Doh.

* Changes after review.

* Better solution that doesn't change the public API.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-02-02 04:51:37 +01:00
David Cosgrove
085e20eda8 Fix bug drawing double bond on very small canvas. (#6026)
* Fix bug drawing double bond on very small canvas.

* Changes after review.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-01-31 17:33:05 +01:00