Files
rdkit/Code/Geometry/Transform2D.h
David Cosgrove 774892a9ab 2ddrawenhancements2931 (#2979)
* 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>
2020-03-10 17:33:59 +01:00

86 lines
2.5 KiB
C++

//
// Copyright (C) 2003-2006 Rational Discovery LLC
//
// @@ 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 <RDGeneral/export.h>
#ifndef __RD_TRANSFORM2D_H__
#define __RD_TRANSFORM2D_H__
#include "Transform.h"
#include <Numerics/SquareMatrix.h>
namespace RDGeom {
class Point2D;
const unsigned int DIM_2D = 3;
class RDKIT_RDGEOMETRYLIB_EXPORT Transform2D
: public RDNumeric::SquareMatrix<double> {
public:
//! \brief Constructor
/*!
Initialize to an identity matrix transformation
This is a 3x3 matrix that includes the rotation and translation parts
see Foley's "Introduction to Computer Graphics" for the representation
Operator *= and = are provided by the parent class square matrix.
Operator *= needs some explanation, since the order matters. This transform
gets set to
the combination other and the current state of this transform
If this_old and this_new are the states of this object before and after this
function
we have
this_new(point) = this_old(other(point))
*/
Transform2D() : RDNumeric::SquareMatrix<double>(DIM_2D, 0.0) {
unsigned int i, id;
for (i = 0; i < DIM_2D; i++) {
id = i * (DIM_2D + 1);
d_data[id] = 1.0;
}
}
void setToIdentity();
void TransformPoint(Point2D &pt) const;
void SetTranslation(const Point2D &pt);
/*! \brief Set the transform so that the specified points are aligned
*
* The resulting transformation will align pt1 with ref1, and rotation
* pt2 such that the line betweem (pt1, pt2) will align with
* with the line (ref1, ref2)
*/
void SetTransform(const Point2D &ref1, const Point2D &ref2,
const Point2D &pt1, const Point2D &pt2);
/*! \brief Set the trans form to counterclock wise rotation by the specified
*value around point
*
* ARGUMENTS:
* - pt : point about which to rotate
* - angle : the angle by which to rotate, in radians
*/
void SetTransform(const Point2D &pt, double angle);
private:
};
} // namespace RDGeom
/*! \brief Combine two transforms and return the results as a new transform
*
* The order is important here, on two transforms t1 and t2
* t3 = t1*t2
* The resulting transform t3 has the folliwng effect
* t3(point) = t1(t2(point))
*/
RDKIT_RDGEOMETRYLIB_EXPORT RDGeom::Transform2D operator*(
const RDGeom::Transform2D &t1, const RDGeom::Transform2D &t2);
#endif