156 Commits

Author SHA1 Message Date
Brandon Novy
efa7a32c3c 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-16 04:59:00 +02:00
Ricardo Rodriguez
9e301c15d6 Normalize rings (#9208)
* normalize rings

* update tests

* update doctests

* update release notes
2026-04-01 05:37:02 +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
Ricardo Rodriguez
7b7a8a4e17 Refactor iostreams includes (#8846)
* refactor iostreams includes

* restore ostream to MonomerInfo.cpp
2025-10-08 16:08:01 +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
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
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
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
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
Greg Landrum
f797113a16 cmake cleanup (#6814)
* add RDKIT_CFFI_STATIC option
minimallib cmake cleanup

* clean up a lot of boost::iostreams nonsense

* find_package(boost cleanup

* update the swig wrappers

* updates to psql

* get the Qt demo working again

* fix? coordgen

* only use std::regex in moldraw2d test

this is consistent with the other tests

* cleanup the serialization stuff too
2023-11-10 15:32:54 +01: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
7c52b0937d Fix auto reference. (#6005)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-01-25 14:30:09 +01:00
Greg Landrum
eb2114ab8e adjust test results for newer freetype versions (#5979)
there seems to be at least one larger change with freetype 2.11.1
2023-01-18 05:00:33 +01:00
David Cosgrove
3e2af9309d Fix ellipse extremes calculation. (#5948)
* Fix ellipse extremes calculation.

* Fix tests.

* fix a typo I made during the merge

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2023-01-10 12:19:44 +01:00
David Cosgrove
facb15f703 Github5899 (#5912)
* Fixed typo in comment.

* Fixed tests that were failing on Raspberry pi.  Highlight rectangle corners coming out in different orders.

* Tidy up a bit.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2023-01-03 05:50:04 +00:00
Paolo Tosco
f0c1f7fc23 Add updateMolDrawOptionsFromJSON() (#5630)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-10-10 04:41:35 +02:00
David Cosgrove
eca3f4e67f Github5592 (#5596)
* Use convex hull to order points in bond highlights polygon.

* Extra comment after review.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-09-26 10:58:12 +02:00
David Cosgrove
40e27a65bd Fixed drawing of O in aldehydes. (#5515)
* Fixed drawing of O in aldehydes.

* Added DrawColour::operator!=.

* Remove unused variable.

* Export doLinesIntersect for test.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2022-09-12 04:23:38 +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
David Cosgrove
d32cf91c2c Fix bug in bond joins (#5482)
* Fix bug in smoothBondJoins caused by not clearing singleBondLines_ in resetEverything.
Updated test results.

* Changes as result of review.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-08-03 13:16:49 +02:00
David Cosgrove
f9b47d907f Add ACS1996 drawing style (#5425)
* Started on ACS 1996 drawing mode.
Significant change (not by itself, sadly) is that MolDrawOptions::lineWidth has changed from int to double to allow for ACS requirement of 0.6px bond widths.

* Wavy lines and dashed wedges.

* Better dashed wedges.

* Rounder wavy bonds, same as SVG.

* Added FreeSans font for ACS1996 mode.

* Add help functions to write enum classes to ostream.

* Dashed wedge separation now 2.5px between line edges rather than line middles.  Therefore wider gap between lines.

* Increase offset for wavy bond.  Get classes for atoms and bonds in wavy bond correct.

* For SMILES input, option to force wavy and crossed bonds for unspecified stereochem.

* Tidy debugging.

* Extra space round atom labels.

* Extra space between chars in freetype string.

* Reformats.

* Change double bond offset.

* Improve ring double bonds.

* Simple non-ring double bonds all working.

* Tidy.

* All double bonds seem good.

* Remove redundant function.
Move calcTripleBondLines into DrawMol for consistency with calcDoubleBondLines.
Use doubleBondOffset for wavy lines.

* Correct spacing between FT chars.

* Tidying.

* Use MolBlock wedging if there is any.  Needs to be made an option.

* If dashed wedge thick end has bonds of it, stop one dash short.

* Adjust solid wedge ends to line with attached bonds.

* Width of wedge ends now based on double bond separation.

* Change catch_tests.cpp

* Rounder waves in wavy lines.

* Dashed wedges same width even if one dash less..

* Embedded Roboto-Regular font in code.

* Fix docstrings.

* doubleBondTerminal swapped ends.
Deal with O2 - 2 terminal atoms of degree 1.

* Fix terminal double bonds.

* Slightly fatter truncated wedge bonds.

* Fix crash on complicated double bonds.

* Control more assert tests with DO_TEST_ASSERT.

* Fix 2 colour solid wedges.
Fix slanted wedge for morphine (test1_5).

* Change definittion of multipleBondOffset to fraction of mean bond length.

* Don't slant end of solid wedge to atom symbol.

* Fix wiggle separation.

* Fix 2-colour terminal double bonds.

* Fix colours on triple bonds.

* Don't attempt to draw non-existent points in triangle..

* Symmetric bond for P=O and like.

* Fix query bonds.

* Reformatting.

* Tidy up use of font.

* Add FreeSans font and license to $RDBASE/Data/Fonts.

* Draw unspecified stereo as unknown.

* Add check_file_hash.

* Tidying.

* Tidying.

* Start Python wrappers.

* Fix solid wedges for 3-connected atoms.

* Docstrings.

* Tidying.

* Alter width of bond highlights in ACS 1996 mode.

* Expose setACS1996Options and mean BondLength in Python.

* Expose drawMolACS1996Cairo in Python.
Docstrings.

* Extra padding between legend and picture in flexicanvas.

* Python tests.

* Tidy catch tests.

* Tidying.

* Fix catch tests.

* Fix no Freetype tests.

* Draw solid wedge more sensibly..

* Fix bond end at solid wedge.

* Tidy.

* Fix Python Cairo build issues.

* Fix wedge end shape for terminal double bonds.

* Hide the joins at the bond ends.

* Fix gcc pickiness.

* Extra test for no atom labels.

* Change where it looks for FreeSans.ttf for ACS1996 drawings.

* Same number of waves for wavy bonds in SVG and Cairo.

* Same number of waves for wavy bonds in SVG and Cairo.

* rename unspecifiedStereoIsUnknown to markUnspecifiedStereoAsUnknown and move to MolFileStereochem.h

* refactor use of iterators

* py docs update

* undo a bunch of bad formatting changes

* remove FreeSans

* get windows builds working

* Fix problem with Windows build.

* Changes in response to review.

* Align description of unspecifiedStereoIsUnknown in C++ to match Python.

* Still working on file open modes.

* Took out extraneous functions for drawing in ACS1996 mode, including the one that was breaking the windows build.

* Add RDKIT_MOLDRAW2D_EXPORT.

* Fix expected test results.

* Clarified warning.

* RDKIT_MOLDRAW2D_EXPORT missing.

* Windows!

* Update Code/GraphMol/MolDraw2D/rxn_test1.cpp

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2022-07-21 18:11:33 +02:00
David Cosgrove
3856398727 Github5420 (#5421)
* Fix #5420.

* Tidy.

* Highlights stay parallel to bonds.

* Change way DrawShapeEllipse is defined, to make it same as DrawShapeArc.

* Change way DrawShapeEllipse is defined, to make it same as DrawShapeArc.

* Make highlight circles bigger when the bond highlights missed initially.

* Update expected test result.

* Update expected test result.

* Turn on check hash code.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-07-20 13:39:10 +02:00
David Cosgrove
b7c9a8b3b7 Add class info for wavy bonds in SVGs. (#5358)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2022-06-13 11:16:51 +02:00
Eisuke Kawashima
27f711a658 Run clang-tidy (readability-braces-around-statements) (#4977)
https://github.com/rdkit/rdkit/pull/3024#discussion_r526549843
2022-03-10 08:00:10 +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
Paolo Tosco
0d8e985c38 queries containing AtomAnd should not be considered atom lists (fixes #5006) (#5007)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-02-14 04:58:27 +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
Eisuke Kawashima
11532089de Run clang-format against cpp (#4358) 2021-10-20 04:25:27 +02:00
Paolo Tosco
788f3ce02c Fixes #4496 (#4497)
* wip

* fixes #4496

* reverted file committed by mistake

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-09-13 04:54:26 +02:00
Paolo Tosco
406f64673a Expose atomColourPalette as JSON drawOption (#4337)
* expose atomColourPalette as JSON drawOption

* changes in response to review

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-07-14 11:04:04 +02:00
David Cosgrove
efa20a811c Test comparing SVGs via hash code - ready for review (#4199)
* Changed SVG output so all coordinates are to 1 decimal place.
Adjusted tests accordingly.

* Checking test1 SVGs via hashcode.

* Added testing of all generated test files by comparing hash-codes.
The few cases where this doesn't work are mentioned in the code.

* close streams

* Close files after writing - Windows won't delete them otherwise.

* Changes post-review.

* Proposed change post-review for further discussion.

* Use MolDraw2D_details::doubleFormat.

* Copied improved check_file_hash() from catch_tests.cpp.
Updated a few hash codes.

* Copied improved check_file_hash() from catch_tests.cpp.
Updated a few hash codes.
Added hash codes for no-Freetype version.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2021-06-17 16:01:26 +02:00
Greg Landrum
e627e70641 make a test more permissive (#4197)
* make a test more permissive

* only do that if freetype is installed
2021-06-02 09:55:43 +02: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
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
Greg Landrum
2c53876ebd MoDraw2D: Get tests working without freetype (#3923)
* make moldraw tests work without freetype

* update azure devops link

* turn off freetype for the limitexternal builds
2021-03-15 04:58:03 +01:00
Paolo Tosco
cceb53a083 Fixes #3852 (#3856)
* fixes #3852
- width should not be implicitly cast to unsigned int
- coordinates should not be rounded ahead of using them in context, as the context will do that with interpolation/antialiasing when generating the bitmap

* - removed another occurrence of std::round
- fixed test that was expecting an integer value which should instead be float

Co-authored-by: Paolo Tosco <paolo.tosco@novartis.com>
2021-03-01 17:00:33 +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
5715f61f9c Fixes #3216 (#3772) 2021-01-29 13:31:01 -05:00
Greg Landrum
d1be88c39a A few small tweaks to the drawing code (#3464)
* change min font size to 6

* tweak dash counts in wedged bonds

* tweak dative arrows

* allow radicals to be turned off in MolDraw2D
2020-10-04 10:28:50 -04:00
Greg Landrum
f41aa033d4 clang-format MolDraw2D (#3463) 2020-10-04 06:03:43 +02:00
David Cosgrove
59dad32e13 Fixed bad draw scale in drawMolecules. Github3391. Take 2. (#3424)
* Fixed bad draw scale in drawMolecules. Github3391.

* Fixed inconsistent font scale.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-10-04 05:54:44 +02:00
David Cosgrove
cc705a2f55 Scale line width3305 (#3380)
* Fixed expected test results.

* Implements Github 3305.
Line widths don't scale by default.  Line widths are now floats rather than ints.

* Suggestion that testGithub565 be removed.

* Corrected comment.

* Fixed test case.

* Added scaleBondWidth to Python wrappers.

* Fixed expected test values.

* Removed testGithub5.

* Added draw option to scale highlighted bond width.

* Put all the tests back in.

* Tweaked tests to allow for difference in scale between Freetype/No-Freetype images.

* Extra write for CI error.

* Extra write for CI error.

* removed extra write for CI error.

* update expected results
remove debugging output

* Fixed stroke-width to 1 decimal place in SVG files.  Altered tests to cope.

* update expected results for python tests

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-09-18 06:44:40 +02:00
Greg Landrum
0b438197c7 Add MolDraw2DJS (#3376)
* backup, does not work

* backup

* baby steps

* basics are now working

* more progress

* add substructure highlighting

* get the FT stuff working too

* get the FT stuff working too

* empirical corrections to dashed bonds

* enable coordgen support

* change min font size

* support dashed lines

* some cleanup

* support all MolDraw2D options when parsing from JSON

* parse MolDraw2D options from JSON

* show stereogroup labels when they are present

* switch to using the new CIP labels in minilib

* update demo to show controlling options

* move all the JS code into jswrapper.cpp
pass the canvas itself instead of the id to the JS functions
introduce offset

* remove extra emscripten load

* cleanup debugging stuff

* update freetype tests

* update non-freetype tests

* changes in response to review
2020-08-31 17:09:16 -04:00
lummyk
36ab603d9a Replace fill-opacity= with fill-opacity: (#3368) 2020-08-31 09:29:42 +02:00
David Cosgrove
f4a85cf9cb Annotation clashes with symbols on small drawings. #3262 (#3263)
* Turns off minFontSize when drawing annotation, to avoid clashes with other parts of the picture.

* Test case for annotations in small pictures.

* Fixed obvious howler in PNG test for small annotations.  Thanks Greg.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
2020-07-03 14:54:21 +02:00
David Cosgrove
938981b056 Added call to test legends. (#3252)
Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-06-25 06:27:36 +02:00
David Cosgrove
bc9e4d6478 Support using FreeType for text rendering (#3237)
* First working version with DrawText classes, original functionality only.  No font scaling.

* Added font scaling.

* Added atom colours.

* First stab at freetype text drawing.  A stash prior to major surgery.

* Freetype seems to be working.  On to whack-a-mole.

* Added class flag to atom labels and annotations.

* Another intermim commit whilst re-factoring all string drawing code from MolDraw2D.

* Fixed scaling and implemented max font size.

* Fixed bugs in non-FT Cairo and SVG drawing.

* More re-factoring of drawStrings - now creates StringRwct for each char in all strings.

* More re-factoring of string drawing - all mentions removed from MolDraw2D, I think..

* Working native Cairo, simple tests.

* Working native Cairo, simple tests.

* Padding roumd rectangles.

* Working FT Cairo, FT SVG, native SVG, simple tests.

* Two line labels mostly sorted. Native SVG wrong.

* Two line SVG labels sorted.

* Two line SVG labels sorted.

* Tidied out debug writes.

* Tweaked merge.

* Annotations working, radicals now failing.

* Fixed radicals crash.

* All tests passed for freetype drawings.  Grid drawings not right.

* Fixed bug in grid drawings.

* Better font size.

* Fixed legends in grids.

* Fixed rect intersection bug.

* Tidied up font sizes.

* moldraw2DTest1 all passing.

* All catch tests pass.

* Few rixes, and reactions look ok.

* Added minimum font size.

* Fixed radical drawing when max/min font size hit.

* Interim cmmmit, most test1.cpp working.

* Fixed uninitialised min_font_size_ in DrawText.  Took out use of MolDraw2D::setFontSize() which probably needs to go back in at some point.

* More test1.cpp passing.

* test1.cpp all pass, freetype and non-freetype

* Fixed superscripts hitting min font size in test860.  Made superscripts and subscripts same size.

* testc.pp all pass.

* Fixed bug in freetype text. All testt1.cpp pass.

* All tests passed.d

* Added option for different font.

* Added option for explicit terminal methyls.

* Added option to explicitly not use Freetype in drawers.  Used same in catch_tests.cpp.

* Got sense of NO_FREETYPE wrong in catch_tests.cpp.  D'oh!

* Fixed Python draw tests.

* Added new options to JSON interpreter.

* Fixed scale of text in contoured plots.

* Added optional molecule to grid drawer to help set scale.

* Fixed Python wrappers  for drawing 2D grids .

* Added Greg's CMakeLists.txt

* Moved fonts out of code tree.
Improved handling of font files not found, including logging to rdWarningLog.

* Interim commit.

* Tidied up some namespace std issues.

* Reverted to previous version.
Took out 'using namespace std;'

* update expected java results

* Added multi-line legends.  Also carves out a reserved bit for the legend, and sets the font size so the legend will fit.

* enable annotations on windows with freetype

* Removed stray font file.

* Removed stray font file.

* Re-instanted fontSize() and setFontSize(), though with change of units.

* Added RDK_BUILD_FREETYPE_SUPPORT to cmake.

* re-expose the fontsize controls to python.
document API change w.r.t. font size

* Update ReleaseNotes.md

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
Co-authored-by: greg landrum <greg.landrum@gmail.com>
2020-06-23 17:31:50 +02:00
David Cosgrove
5f7affafb6 Fix drawing of N plus (#3165)
* Fixed poor position of + charge in S NH2+ group.  Also made it say Cu2+ rather than Cu+2.

* Fixed bug where H of [NH+](C)(C)C sometimes went on top of bond.

Co-authored-by: David Cosgrove <david@cozchemix.co.uk>
2020-05-25 09:07:03 +02:00