11 Commits

Author SHA1 Message Date
Greg Landrum
83cf752eb0 extract continuous lines from the conrec code (#6676) 2023-09-15 09:00:26 +02:00
Paolo Tosco
79037b767f Enable building MinimalLib as a plain JS file for usage in legacy/headless browsers (#5999)
* - fix indentation
- fix regex check (which currently always fails)

* wip

* - added clearMolBlockWedgingInfo()
- added invertMolBlockWedgingInfo()
- MinimalLib::generate_aligned_coords() now inverts stereochemistry if a rigid-body alignment transformation caused chiality inversion
- MinimalLib::generate_aligned_coords() now clears stereochemistry if coordinates changed
- added JSMol::clear_prop() to the already existing JSMol::get_prop() and JSMol::set_prop()
- renamed commonchem to rdkitjson in JS unit test
- added relevant unit tests

* fixed mistake in logic

* - added add_hs_in_place() and remove_hs_in_place() to the JS MinmalLib
- added relevant tests

* - removed check for existence of a property ahead of clearing it as it is not necessary; updated the clearProp docstring to reflect this
- updated the MolFileStereochem.h docstrings based on review comments and fixed a typo
- fixed two (legitimate) compiler warnings as get_molblock() and get_v3kmolblock() should return nullptr and not a pointer to an empty string; added tests for this as there was none
- in MinimalLib/common.h, moved the check of whether a molecule has undergone a flip around the Z axis to a function in the anonymous namespace
- in MinimalLib/common.h, added logic to preserve original wedging (and eventually invert it) also when alignOnly is set to false, in case the wedging is all within the constrained scaffold
- added thourough testing of the wedging logic on both CFFI and JS sides

* - added equality operator to CXXAtomIter and CXXBondIter classes such that they can used with implicit loop STL algorithms
- added relevant unit tests

* fix Windows build

* - enable building MinimalLib as a plain JS file for usage in legacy/headless browsers
- support alternative way to draw an ellipse on legacy canvas without ellipse support
- update tests.js to test both the standard and the legacy version of MinimalLib
- update demo.html to work with both versions of the library and automatically select one based on browser support of WebAssembly
- fix a regression in demo.html caused by a change in signature of generate_aligned_coords

* reverted most changes

* changes in response to review

* restored demo.html
added a comment to Dockerfile_legacy_browsers explaining how to test in a legacy browser

Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2023-01-27 10:28:48 +01:00
Greg Landrum
6a56f02a84 Fixes #5383 (#5391)
* Fixes #5383

* response to review
this is a better fix
2022-07-05 12:55:33 +02:00
Greg Landrum
8676e3da64 Fixes #5386 and #5389 (#5387) 2022-07-01 06:36:26 +02:00
Paolo Tosco
27b92a24ae Fixes JS build broken by #4948 (#5042)
Co-authored-by: Tosco, Paolo <paolo.tosco@novartis.com>
2022-02-24 06:35:32 +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
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
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
Greg Landrum
96800b0a86 moldraw2djs should not close all polygonal paths (#3634) 2020-12-12 06:10:13 +01:00
Paolo Tosco
9c64df9a73 fixes #3540 (#3573) 2020-11-24 05:00:55 +01: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