mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-06 22:39:55 +08:00
* First pass of fixing layout of OH/NH type drawing. * Fixed scale for N/S NH type groups. * Fixed bond end points with new display of heteroatoms. * Fixed case where it drew aromatic dashed bonds in wrong ring for morphine. * Minor edit. * Fixed non-drawing of chiral bonds. * Removed use of boost for_each. * Modern atom traversal. * Put in fixed scale for drawings. Made drawMolecule() take note of prepareMolsBeforeDrawing. Updated more iterators to modern idiom. * Added fixed bond length for drawing. * Fixed drawing of CH4, NH3 etc. * Stash of working but ugly, prior to re-work. * Better, simpler splitting of atom symbols. * Took clang-tidy's advice about use of override. * Tidied up drawing of text strings. * Tweaked what is classed as vertical bond in drawing. * fixedBondLength now down-scales if it would overflow the draw window. * Some tidying. * Tests for new parameters in JSON. Fixed some existing tests where, for example, scale on picture is now different. * Added option to rotate 2D draw coords before drawing. * First pass at highlighting atoms in multiple colours. Circles only at the moment. * Line width scales if big enough. * Tweaked SVG text drawing. * Added highlighting with more than 1 colour on an atom. C++ only. * Fixed some issues with widths of highlights in a frustrating game of whackamole. Updated some tests accordingly. * Added Python wrapper for new drawing code. * Removed debugging writes. * Added C++ test for multi-coloured highlights. * Added python test for multi-coloured highlights. * Attempt to show radicals. * Tidied up radicals in drawing, including a bullet instead of full stop in SVG. * Fixed catch_tests.cpp for MolDraw2D. * Fixed crash in Python wrappers on OSX. * Fixed test5_2.svg bug (trailing </tspan>). Made wavy line width scale as other lines do. * Improved placing of charges. * We're already in the future. * Fixed a number of bugs that made drawMolecules not set the scales properly. * Fixed Cairo wavy line width. * Fixed non-closure of collision boxes. * Added maximum font size for text, with tests. * Addressed all Greg's first PR change requests. * Fixed crash in extractAtomsymbols. * stop using coordgen and adjust tests to reflect that there's a bit of reformatting in here too * Fixed layout of reactions. * Fiddled with moldraw2DTest1 tests again. * Fiddled with catch test. * Fixed istope postion in W atom labels. * Minor tweak to cairo, * update expected results Co-authored-by: David Cosgrove <david@cozchemix.co.uk> Co-authored-by: Greg Landrum <greg.landrum@gmail.com>
48 lines
1.3 KiB
C++
48 lines
1.3 KiB
C++
//
|
|
// Copyright (C) 2015 Greg Landrum
|
|
//
|
|
// @@ All Rights Reserved @@
|
|
// This file is part of the RDKit.
|
|
// The contents are covered by the terms of the BSD license
|
|
// which is included in the file license.txt, found at the root
|
|
// of the RDKit source tree.
|
|
//
|
|
|
|
#include <GraphMol/MolDraw2D/MolDraw2DDetails.h>
|
|
#include <cmath>
|
|
#ifndef M_PI
|
|
#define M_PI 3.14159265358979323846
|
|
#endif
|
|
|
|
// ****************************************************************************
|
|
|
|
namespace RDKit {
|
|
namespace MolDraw2D_detail {
|
|
// implementation from $RDBASE/rdkit/sping/pid.py
|
|
void arcPoints(const Point2D &cds1, const Point2D &cds2,
|
|
std::vector<Point2D> &res, float startAng, float extent) {
|
|
// Note: this implementation is simple and not particularly efficient.
|
|
float xScale = (cds2.x - cds1.x) / 2.0;
|
|
float yScale = (cds2.y - cds1.y) / 2.0;
|
|
if (xScale < 0) {
|
|
xScale *= -1;
|
|
}
|
|
if (yScale < 0) {
|
|
yScale *= -1;
|
|
}
|
|
|
|
float x = std::min(cds1.x, cds2.x) + xScale;
|
|
float y = std::min(cds1.y, cds2.y) + yScale;
|
|
|
|
int steps = std::max(static_cast<int>(extent * 2), 5);
|
|
float step = M_PI * extent / (180 * steps);
|
|
float angle = M_PI * startAng / 180;
|
|
for (int i = 0; i <= steps; ++i) {
|
|
Point2D point(x + xScale * cos(angle), y - yScale * sin(angle));
|
|
res.emplace_back(point);
|
|
angle += step;
|
|
}
|
|
}
|
|
}
|
|
}
|