Commit Graph

174 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
David Cosgrove
e6b549da36 Github9280 (#9300)
* Fix setFontScale for maximum and minimum font sizes.

* Fix other test.  Add hashcodes.
2026-05-29 05:51:55 +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
Yakov Pechersky
0986d22c58 Deterministic kekulize, independent of atom and bond order (#9125)
* Make kekulization deterministic

* Add tautomer order-independence regression (python)

* Adjust tautomer tests for deterministic kekulization

* Update graphmol wedged-bond kekulization checks

* SmilesParse: update aromatic bond index expectations

* SmilesParse: refresh cxsmilesTest expected files

* Depictor: update testDepictor expected MolBlocks

* Depictor: update depictorCatch expectations

* Depictor Wrap: update expected MolBlock for pyDepictor

* MarvinParse: update testMrvToMol expected outputs

* FileParsers: refresh testAtropisomers expected outputs

* FileParsers: update tests for deterministic kekulization

* MolDraw2D: refresh brittle bond assertions

* RascalMCES: update expected cluster size

* MinimalLib: make cffi wedging check order-independent

* documentation fix

* MinimalLib: update Kekulé bond table in aligned-coords test

* Hoist duplicated lambdas to TEST_CASE scope

* Remove unused originalWedges variable

* Remove redundant bounds check; clarify wedge-end preference

* Pre-sort allAtms by wedge-end + rank

* Use mol.atomNeighbors() for neighbor iteration

* Check inAllAtms before linear-scanning done

* Drop redundant optsV/wedgedOptsV sorts

* Remove unused Canon.h include

* Add canonical parameter to Kekulize; skip ranking during sanitization

* Test canonical re-kekulization preserves stereo across atom orderings

* MinimalLib: update Kekulé bond orders in invertedWedges

* Change Kekulize canonical default to false, expose in Python wrappers

* keep rank order, push_back

* Revert "RascalMCES: update expected cluster size"

This reverts commit a81bb39495.

* docstring change

* expose new flag to python wrapper

* document changes in ReleaseNotes.md

* revert minimallib test changes again

* canonical = true defaults

* Revert "revert minimallib test changes again"

This reverts commit 039e1d84da.

* Reapply "RascalMCES: update expected cluster size"

This reverts commit 7b83a7a3e8.

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2026-03-19 08:43:13 +01:00
David Cosgrove
40fe7ef681 Better solid triangles (#8943)
* Change the way solid wedges are drawn to use larger polygons.

* Better variable name.
2025-11-18 09:47:24 +01: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
David Cosgrove
f90b4382ca Fix drawing of very short arcs in lasso. (#8706) 2025-08-15 08:25:32 +02:00
David Cosgrove
b9666d93b8 Fix offsets for DrawMoleculeWithHighlights. (#8680)
* Fix offsets for DrawMoleculeWithHighlights.

* No Freetype test.

* Trigger Build

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-08-14 07:17:31 +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
f00735a310 Fix arrowhead8500 (#8504)
* Fix the arrow heads.

* Tidy.

* Looser tolerance on test.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-05-08 06:48:54 +02:00
Greg Landrum
86141183c1 Moving towards getting all tests to pass when using the new stereo code (#8409)
* Fixes #8379

* check in some working tests

* test passes

* test passes

* test passes

* test passes

* test passes

* ensure that the invariants flush the streams on failure

* tests pass

* test passes

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* tests pass

* Fixes #8391

* tests pass

* fix a test with legacy
not clear why this was not causing problems before

* make a test work

* Fixes #8396

* gcc builds work

* fingerprint tests pass

* mention backwards incompatible change

* fix a problem with FindMolChiralCenters

* more testing details

* enable the test status output

* Fixes #8432

fix a bug in double-bond stereo handling for template matching

* all depictor tests pass

* use the new-stereo chiral ranks in the depiction code

* always assign new-stereo chiral ranks

* make _ChiralAtomRank a computed property
This is analogous to _CIPRank

* tweak to the way the atom ordering is computed for 2D coordinate generation

* update two expected results

* backup

* response to review

* tests pass

* tests pass

---------

Co-authored-by: = <=>
2025-04-15 14:00:32 +02:00
Greg Landrum
33fda86856 Fixes #8308 (#8335)
* Fixes #8308

* fix typo
2025-03-19 12:00:39 +01:00
Greg Landrum
fe5ccb7d47 Feat/use draw color in drawString() (#8334)
* change exception type for bad user input in the MCH code

* use the current draw color with drawText
2025-03-08 10:46:39 +01: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
249ff92e96 Option to put padding round elements of reaction. (#8216)
* Option to put padding round elements of reaction.

* Rename the option to componentPadding.

* Missed one.

* Correct filename.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-01-31 05:50:03 +01:00
David Cosgrove
0f3f7c39f8 Fix reaction panel bug. (#8217)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-01-28 14:06:59 +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
78b11c8c12 Reaction rendered badly with small canvas size (#8211)
* Remove forcing minFontSize to 12 for reactions.

* Add hash code test.
Run Clang-format.

* Typo

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2025-01-26 07:35: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
tadhurst-cdd
0de215a1f8 Fix canonicalization of stereogroups (#7041)
* 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

* test changes

* 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

* Merge branch 'master' into pr/specialQueries

* changes from previous PR

* Iclude false chiral

* rigorous enhnced stereo canoncalization

* Added more tests and clenup

* removed commented out code

* corrected init of SmilesWriteParams

* added MolFileStereoChem.h to the header files

* Renamed Rxn parser to MrvBlockToChemicalReaction

* To make catch2 work, and match the checksum

* Fixed Structchecker errors

* fix CI for DetermineBonds catch test

* error in catch_test for CI

* Allow custom  smileWriteParams  in GetMolLayers

* misnamed entry point

* ReactionFromMrvString change name

* remove adding writeParams to GetMolLayers

* make rigorous enhanced stereo the default, and fix tests

* only one abs group no longer needs Rigorous Enhanced treatment

* changed string_view to string in catch test

* Canonicalize Enhnaced Stereo only resturne unique smiles

* Now allows or and and groups together

* internal routines inside detail scope

* fix test error

* changed string back to string_view and fixed a CHECK

* Fixes for PR review tests

* Fix RDKit_Book.rst failure on build test

* fix xqm sql test

* updated expected files for cxsmiles_test

* Fixed removal of atom attrs

* Fixed tests after merge of master

* More efficient version of Stereo Groups Canonicalization

* Fixes for ctests

* removed debug code

* readded cipLabel test

* fix generalizedSubstruct/catch_tests.cpp error

* hueristics to improve speed

* Rationaized control of abs groups

* removed unused routine

* added rigorous stereo group treatment to test

* some suggested changes

* Changes per PR review and removed some changes to smiles

* Fixed CI errors

* changes per PR review

* more PR review vhanges and cleanup

* Fixed PSql PKL change

* changes as per PR review

* Restored error type for bad mols for canonicalizeStereoGroups and added a test

* Merge master and fix test in MolDraw2D

* Fix for randomize test error and other PR review comments

* Removed unsued variable to fix mac CI

* do not force aromatization in canonicalizeStereoGroups

* changes as per PR review

---------

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2024-10-11 17:09:18 +02:00
Greg Landrum
da6cd73168 Run clang-format across everything (#7849)
* run clang-format-18 across Code/*.cpp and Code/*.h

* run clang-format-18 across External
2024-09-26 13:39:02 +02:00
Greg Landrum
bb066c43f4 add mol processing API (#7773)
* fix aliasing bug in MultithreadedSDMolSupplier

* update GeneralFileReader to v2 API

* add backwards incompatibility note

* v1 of this

* The helper function needs to be inline

* forgot the tests

* allow non-threadsafe builds

* MultithreadedMolSuppliers can now be destroyed without being used.

This was previously not possible

* add callbacks to the multithreaded readers

* document the new functions

* switch to storing the queues in unique_ptrs

* does not work

* only do those tests when in MT mode

* more generalfilereader cleanup

* tests pass

* passes tests

* extremely basic python wrapper

* better wrapper

* does not work

* tests pass

* test data

* fix failing test on ARM macs

we need to followup on why the wedging is different here

* move some stuff to the cpp file

the idea is to have the windows DLL builds not break

* fix(?) win64 linkage problems

* remove a warning in non-multi-threaded builds

* fix non-multi-threaded work

* well, at least local windows builds work

* remove duplicated code

* refactoring
simplification?

* simplify mutext handling

* review suggestions
2024-09-19 18:42:25 +02: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
Paolo Tosco
e4f4644a89 - Expose multicolor highlights to MinimalLib (#7787) 2024-09-03 21:03:40 +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
6bc3aa4b47 Make CXSMILES writer use the default conformer ID (#7415)
* Fixes #7414
Fixes #7409

* skip that test if cairo is not enabled
2024-05-09 14:43:49 +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
Ricardo Rodriguez
73e91a6344 Fixes #7318 (#7319)
* fix hybridization for atoms with outgoing dative bonds

* expose and wrap C++ numPiElectrons

* deprecate AtomPairs.Utils.NumPiElectrons

* add & update tests

* fix draw2d test

* update expected hash

* add hybridization test

* move numPiElectrons to Atom.h

* take reference instead of ptr
2024-04-03 15:34:37 +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
Greg Landrum
d1b9331a36 Fixes #7122 (#7126) 2024-02-03 06:47:28 +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
David Cosgrove
a868986c98 Better lasso highlighting (#6936)
* Diatomic tests working.

* Working with simple multi-atom tests.

* Most tests not working.

* Minor tidy.

* Almost working.  Failure in lasso_highlights_6.svg.

* Intersecting circles looks ok for same radius.

* All seems to be working.

* Better tests.

* Tidy up.

* More tidying.

* Fix warnings.

* Fix warnings.

* Change REQUIRE to CHECK.

* Changes after review.
2023-11-28 06:54:13 +01:00
Greg Landrum
2957ab4576 switch to catch2 v3 (#6898)
* switch to catch2 v3
Fixes #6894

* fix a couple of problems noticed in the CI builds

* more warning cleanup

* changes in response to review
2023-11-15 06:45:42 +01:00
David Cosgrove
24c11d780f Bad lasso (#6751)
* Better separation of lines.

* Only put atoms in colour list once.

* Test.

* Hash codes.

* Response to review.

* First attempt at fixing stray line.

* Tidier.

* Squared distances.
2023-10-13 15:22:29 +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
David Cosgrove
e4419675c1 Catch meanBondLen of 0.0 (#6699)
* Catch meanBondLen of 0.0

* Change PRECONDITION to ValueErrorExecption.

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-09-08 14:18:26 +02:00