197 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
6fcd3b2798 Lasso highlights (#6653)
* First working lasso.

* Adjust lasso radii in non-overlapping sets of atoms.

* Move MultiColourHighlightStyle enum out of MolDrawOptions class.
Add Python wrappers.

* Update copyright notices.

* Fix bug where order of lines off arc wasn't clockwise, so circle wasn't trimmed properly.

* Use highlight_bond_map in lassos.

* Fix bug in colour selection for multi-coloured lasso bonds.

* Response to review.

* Attempt to add new option to JSON input.

* Fix bug with larger radii.

* Fix yet another bug with the arc tidying.

* Remove separate colouring of bond highlights in Lasso.

* Fix intersection between line and arc not on end of line.

* Another pernickety fix.

* Tidy.

* I should know better than to use the web editor

---------

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-08-31 14:50:49 +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
Greg Landrum
93428d5048 Do not include dative bonds in ring finding by default (#6231)
* change default behavior so that dative bonds are not included in ring finding

* make sure that generating 2D coords does not lose the rings

* cleanup some leftover problems
2023-03-30 18:09:24 +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
Greg Landrum
aa1735705d Swap MolDraw2D from KekulizeMol() to KekulizeIfPossible() (#5976)
* Fixes #5974
Fixes #2164
Fixes #5971

* change in response to review
plus switch off the logging while kekulizing
2023-01-16 09:31:51 +01:00
David Cosgrove
6df3da0966 Fixes Github 5949 (#5950)
* Make arrowhead of dative bond a consistent number of pixels in size, based on doubleBondOffset.

* Improve test.

* Clang noticed incorrect order of panelWidth, panelHeight for some tests.

* Fix some hash codes.

* Give correct github issue number.

* Update hash codes.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-01-11 09:37:47 +01:00
Greg Landrum
e322928028 swap boost::tuple to std::tuple (#5851) 2022-12-16 16:01:19 +01:00
Paolo Tosco
22e99f5e6e MolDraw2D::drawMolecules() should not crash on null molecules (#5503)
* MolDraw2D::drawMolecules() should not crash on null molecules

* changes in response to review

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-09-06 14:42:47 +02:00
David Cosgrove
d209cbd196 Improved bond highlights (#5484)
* First draft.
Polyline round bond joins is smaller.
Continuous highlight bonds mitre.

* Remove historical and now misleading comment.

* Mitre the continuous bond highlights.

* Better bond highlighting with not continuous highlighting.

* Updated hash codes.  Extra test.

* Updated hash codes.

* Script to update hash codes automatically.

* Fix test.

* Fix test.

* Remove debugging file write.

* Removed redundant code.

* More auto.

* Removed newly redundant function.

* More explanation and an extra example/test.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-09-06 12:55:38 +02:00
Paolo Tosco
8a4c208a19 fixes #5259 (#5260)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-05-05 10:14:48 +02:00
Greg Landrum
fd1752e006 disable Info and Debug logs by default (#5065)
* disable the info and debug logs by default

* adjust tests to the newly disabled logs

* add LogStateSetter

* namespace reorg

* add some tests

* remove vestigial code

* switch to using std::vector
2022-03-12 10:04:28 +01:00
David Cosgrove
cd6c915c9e Fix github 5061. (#5063)
* Fix github 5061.

* Update hash code.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-03-07 11:06:51 +01:00
David Cosgrove
f93016a77f Refactor mol draw2 d (#4948)
* MolDraw2D refactoring
- rename setupMoleculeDraw->initMoleculeDraw
- track whether or not initDrawing() has been called
- centralize calls to initDrawing() and clearDrawing() into initMoleculeDraw()
- update svg hashes in tests

* update some expected test results

* support changing font scale and default scale
add reaction test

* does not work... this is hard

* all tests pass

* do something about legends

* docs

* more tests

* more docs

* cleanup

* going around in circles...
hopefully converging

* cleanup

* Single bond skeleton works.

* Simple bond drawing seems to be working.

* Initial addition of atom symbols.

* Stash of not-quite-working atom symbols prior to major surgery.

* Atom symbols seem to be working.  Major surgery not required, just inverted Y coords at the outset.

* Add classes to atom labels.

* Renamed AtomLabel AtomSymbol.

* Add highlights.

* Fix bug from PR4839.

* Molecule note.

* Added atom notes.

* Added bond notes.

* Extract radicals.

* Annotation via new DrawAnnotation class.

* Add brackets.

* Add linknodes.

* Add close contacts.

* Add attachment points.  Fix wavy lines.

* Draw molecules in grid.

* Tidy.

* Fix radicals when font has hit maxFontSize.
Make getDrawCoords work.

* Draw primitives take atom or draw coords.

* Fix legends.

* More fixing for tests.  DrawMol::setScale now takes font scale as well.

* tidy debug writes

* Variable fraction of panel for legend.

* Better legend positioning.

* Fix sub- and super-script spacing.
Added spaces to Freetype strings.

* Basic reaction drawing.

* Reaction highlighting.

* Minor tweak to reacctions.

* Tweaked reaction DrawMol widths.

* Fix atomTags.

* Fix catch tests except contours.

* Contouring working in catch_tests.cpp.

* Fix catch tests.

* AtomSymbol and DrawAnnotation into MolDraw2D_detail.

* DrawMol and DrawShape into MolDraw2D_detail.

* DrawText inot MolDraw2D_detail.

* Machete out.

* DrawText goes private.

* Move some stuff about, such as StringRect to its own header.

* Python wrapper compiles (but crashes when Draw imported).

* More tidying.  Python DrawArrow failing.

* Linux changes.

* Fixed error in DrawShapeArrow spotted by valgrind.
Fixed some warnings from gcc.

* Maybe fixed DrawArrow.

* Added basic argparse interface.

* Added newlines.

* Changes in response to review.
Non-const args in move constructors and operator=.
Added missing classes to MolDraw2D_detail.
Deleted move operator= where it had been forgotten.
Fixed copyright dates.

* Deleted all default c'tors in derived classes.

* Changes in response to review:
Wedge widths now a proportion of mean bond length in draw coords..
Add padding below legend when positioning it.

* Fix tests.

* Fix the private/protected mess of the new classes.

* Moved doesLineIntersect etc.

* Reinstate original alignString for non-FT drawings.

* More faffing about with reaction layouts.

* Fix font sizes in testGitHub3391.

* Fix atom notes fitting inside fat wedges.

* Fix molecule annotation font size.

* More fixes of rectangle/triangle collision detection.

* Test for highlight linewidth multiplier.

* Use push_back not emplace_back.

* Attempt at better Freetype char spacing.

* Option to turn off TEST_ASSERT. Currently off.

* Fixed embarrassing maths to do with wedge fatness.

* More tidying post-review.

* Document highlight_linewidth_multipliers.

* Expose baseFontSize to Python.

* Changes in response to review.

* Allow DrawMolecules molecules to be drawn to different scales.

* Fix bond sneaking between C:8 in, for example, reactions.

* Fix bad re-factoring.

* Fix globbing.

* Changes in response to review.

* Add invariant check.

* Add draw option to fix font size.

* suggested changes

* Update catch test results.

* Fix expected freetype results.

* Fix non-freetype drawers.

* Fin non-freetype test results.

* get the Qt drawer working too

* Fix disappearing reaction highlights.

* Changes as result of review.

* Fixed non-FreeType hash codes for reaction SVGs.  Extra comment in catch_tests.

* reactant highlighting was clearning properties

* Fix for failing contour python test.

* fix a non-freetype problem

* swig wrappers working

* Bump timeouts in test.

Co-authored-by: greg landrum <greg.landrum@gmail.com>
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-02-18 16:30:21 +01:00
Greg Landrum
db15b372a1 Fix some problems turned up by ossfuzz (#4927)
* resolves oss-fuzz #24399

* clean up some undefined behavior

* fix some UB in mergeQueryHs

* be more defensive

* defensive programming

* fix a _cxsmilesBondIdx bug

* more defensive programming
2022-01-22 04:30:06 +01:00
Greg Landrum
67f877b7ca fix bug with wedges being drawn backwards (#4868) 2022-01-10 09:05:28 +01:00
Greg Landrum
f007a93790 Fixes a few MolDraw2D problems (#4839)
* Fixes #4838
DrawString() with alignment argument does not work from Python

* Fixes #4837
MolDraw2D::DrawArc() not exposed to Python

* Fixes #4836
drawArc() starting at wrong angle

* add docs and tests for the alignment argument
2022-01-04 13:28:59 +01:00
Greg Landrum
71b518c67b Allow MolDraw2DCairo and MolDraw2DSVG to determine canvas size based on the molecule (#4772)
* MolDraw2D refactoring
- rename setupMoleculeDraw->initMoleculeDraw
- track whether or not initDrawing() has been called
- centralize calls to initDrawing() and clearDrawing() into initMoleculeDraw()
- update svg hashes in tests

* update some expected test results

* support changing font scale and default scale
add reaction test

* does not work... this is hard

* all tests pass

* do something about legends

* docs

* more tests

* more docs

* cleanup

* going around in circles...
hopefully converging

* cleanup

* response to review
along with a bit of cleanup
2021-12-14 05:22:34 +01:00
David Cosgrove
20a7e00ca0 Github4519 (#4726)
* Fixed calculation of position of SGroup data.

* Updated hash codes.

* Fixed poor placement of SGroupData when drawing in grid.

* Tidier way of setting font size ignoring min and max font sizes.

* More sensible calling of string clash checks.

* Update updated test values.

* Updated comments.

* Changes in response to review.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2021-12-02 14:39:17 +01:00
Gareth Jones
42c8e011e1 Molfile SDD records not properly displayed (#4690)
* Fix and test for Molfile SDD record

* Fix typo
2021-11-16 13:46:27 +01:00
Greg Landrum
074fe80d9a Fixes #4538 (#4539) 2021-09-21 18:16:25 +02:00
Greg Landrum
d6a89b6e61 Fixes #4508 (#4512)
* Fixes #4508

* more testing

* don't be repetitive

* allow logging to work in the catch tests
2021-09-15 16:06:36 +02:00
Greg Landrum
69b143edd0 Swap from RDUNUSED_PARAM to unnamed parameters (#4433)
* cleanup

* more cleanup
2021-08-24 17:19:46 -04:00
David Cosgrove
e2402c76ae Fix incorrect scaling in grid drawing with radicals. (#4163)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2021-06-01 14:56:03 +02:00
Greg Landrum
872b7386ff MolDraw2D: support changing annotation colours (#3919)
* support changing annotation colours

* actuall expose that
2021-03-17 15:20:20 +01:00
Greg Landrum
fbc76aea18 MolDraw2D: collected tweaks and bug fixes (#3930)
* Fixes #2976
Stops re-generating reaction coordinates when that's not required

* add better test

* try to deal with bad font sizes from mol files

* one more expected result update

* try to be smarter about font changes

* suppress a compiler warning

* remove debug output

* update some expected test results
2021-03-17 04:47:44 +01:00
jasondbiggs
f4b68a068b add a new mol draw option to draw wedge bonds with a single color (#3860)
* add a new mol draw option
to draw wedge bonds with a single color rather than two

* change option name, add option to json parser

Co-authored-by: Jason Biggs <jasonb@wolfram.com>
2021-03-15 15:43:47 +01:00
Greg Landrum
36c7c04344 basic h bond support (#3871) 2021-03-06 09:39:13 -05:00
Greg Landrum
0e89b2dbea cleanup a bunch of compiler warnings (#3849)
* cleanup a bunch of g++ warnings

* make it work with clang

* remove some additional warnings based on CI builds

* fix that version number

* stop being verbose when building
2021-02-26 05:10:02 +01:00
Paolo Tosco
5c2a3a8a93 Adds isotopeLabels and dummyIsotopeLabels MolDrawOptions (#3825)
* adds isotopeLabels and dummyIsotopeLabels MolDrawOptions

* changes in response to review

* more changes in respons to review

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-02-24 21:20:01 +01:00
SPKorhonen
14f4b34a6c Facilities for interactive modification of molecule drawing (#3833)
* Split bonds to per-atom parts for interaction

* It would help to commit test fixes also

* Update Code/GraphMol/MolDraw2D/MolDraw2D.h

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

* Update Code/GraphMol/MolDraw2D/MolDraw2DSVG.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2DSVG.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2DSVG.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Update Code/GraphMol/MolDraw2D/MolDraw2D.cpp

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

* Refactored code

* Add space to prevent svg rendering problems

* Fix tests

Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-02-24 16:40:24 +01:00
Greg Landrum
009e593b5c MolDraw2D: first pass at rendering atom lists (#3804)
* first pass at rendering atom lists

* a bit of additional cleanup
2021-02-17 15:25:53 +01:00
Paolo Tosco
b78ff8faa6 Fixes #3744 (#3748)
* fixes #3744

* added a unit test

* fix by stopping with the unnecessary copies

Co-authored-by: greg landrum <greg.landrum@gmail.com>
2021-01-20 11:05:07 +01:00
Greg Landrum
53782cc751 Support rendering LinkNodes (#3662)
* break out the LinkNode processing code

* initial version of linknode rendering

* add another test and fix a minor issue

* boost::format

* fix a bad merge
2020-12-21 15:29:17 +01:00
Greg Landrum
7d3ce119e6 Add molecule annotations/notes to MolDraw2D (#3651)
* first basic pass at molecule notes

FIX problem with updating bounding box based on non-centered annotations

* add chiral flags and simplified stereo annotations

* tests

* molecule annotations are the same font size as atom labels
2020-12-21 11:24:17 +01:00
greg landrum
7564a4af8b Merge branch 'feat/bond_query_drawing' of https://github.com/greglandrum/rdkit into greglandrum-feat/bond_query_drawing 2020-12-17 06:43:49 +01:00
greg landrum
21788d285b Merge branch 'feat/noatomlabels' of https://github.com/greglandrum/rdkit into greglandrum-feat/noatomlabels 2020-12-12 12:07:58 +01:00
greg landrum
aeb8a0d79a Merge branch 'feat/draw_variableattachments' of https://github.com/greglandrum/rdkit into greglandrum-feat/draw_variableattachments 2020-12-12 12:02:21 +01:00
greg landrum
3382458312 Merge branch 'feat/draw_sgroup_data' of https://github.com/greglandrum/rdkit into greglandrum-feat/draw_sgroup_data 2020-12-12 11:52:35 +01:00
greg landrum
15ccf87862 add configuration option to disable atom symbols in the rendering 2020-12-10 18:27:05 +01:00
greg landrum
8527f0bf55 a bit more cleanup 2020-12-09 13:25:35 +01:00