RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
DrawMolMCH.h
Go to the documentation of this file.
1//
2// Copyright (C) 2021-2022 David Cosgrove and other RDKit contributors
3//
4// @@ All Rights Reserved @@
5// This file is part of the RDKit.
6// The contents are covered by the terms of the BSD license
7// which is included in the file license.txt, found at the root
8// of the RDKit source tree.
9//
10// Original author: David Cosgrove (CozChemIx Limited)
11//
12// This class, derived from DrawMol, does multi-coloured highlights.
13// Like DrawMol, it is not part of the public API and should only be
14// used by MolDraw2D.
15
16#ifndef RDKIT_DRAWMOLMCH_H
17#define RDKIT_DRAWMOLMCH_H
18
21
22namespace RDKit {
23namespace MolDraw2D_detail {
24
25class DrawMolMCH : public DrawMol {
26 public:
27 /*!
28 Make a DrawMol that does multi-coloured highlights. Both atoms and
29 bonds can have more than 1 highlight. There's no maximum although more
30 than 4 is very cluttered.
31 \param mol : the molecule to draw
32 \param legend : the legend (to be drawn under the molecule)
33 \param width : width (in pixels) of the rendering
34 set this to -1 to have the canvas size set automatically
35 \param height : height (in pixels) of the rendering
36 set this to -1 to have the canvas size set automatically
37 \param drawOptions : a MolDrawOptions object from the owning MolDraw2D
38 \param textDrawer : a DrawText object from the owning MolDraw2D
39 \param highlight_atom_map : indexed on atom idx, the colours to be used to
40 highlight atoms. Not all atoms need to be mentioned.
41 \param highlight_bond_map : indexed on bond idx, the colours to be used to
42 highlight bonds. Not all bonds need to be mentioned.
43 \param highlightRadii : map from atomId -> radius (in molecule coordinates)
44 for the radii of atomic highlights. If not provided for an atom, the default
45 value from \c drawOptions() will be used.
46 \param highlight_linewidth_multipliers : map from bondId -> int, to change
47 the thickness of the lines used for the highlighting.
48 \param confId : (optional) conformer ID to be used for atomic
49 coordinates
50 */
51 DrawMolMCH(const ROMol &mol, const std::string &legend, int width, int height,
52 MolDrawOptions &drawOptions, DrawText &textDrawer,
53 const std::map<int, std::vector<DrawColour>> &highlight_atom_map,
54 const std::map<int, std::vector<DrawColour>> &highlight_bond_map,
55 const std::map<int, double> &highlight_radii,
56 const std::map<int, int> &highlight_linewidth_multipliers,
57 int confId = -1);
58 DrawMolMCH(const DrawMol &) = delete;
59 DrawMolMCH(DrawMol &&) = delete;
60 DrawMolMCH &operator=(const DrawMol &) = delete;
62
63 void extractHighlights(double scale) override;
66 std::vector<std::unique_ptr<DrawShape>> &bondHighlights);
68 std::vector<std::unique_ptr<DrawShape>> &atomHighlights);
69 // adjust p2 so that the line from p1 to p2 stops where it intersects
70 // the label ellipse for at_idx.
72 void calcSymbolEllipse(unsigned int atomIdx, Point2D &centre, double &xradius,
73 double &yradius) const;
75 std::vector<std::unique_ptr<DrawShape>> &atomHighlights,
76 std::vector<std::unique_ptr<DrawShape>> &bondHighlights);
77
78 const std::map<int, std::vector<DrawColour>> mcHighlightAtomMap_;
79 const std::map<int, std::vector<DrawColour>> &mcHighlightBondMap_;
80 const std::map<int, int> &highlightLinewidthMultipliers_;
81};
82
83// adjust p2 so that the line from p1 to p2 stops where it intersects
84// the ellipse.
86 double yradius, Point2D p1, Point2D &p2);
87} // namespace MolDraw2D_detail
88} // namespace RDKit
89
90#endif // RDKIT_DRAWMOLMCH_H
const std::map< int, std::vector< DrawColour > > mcHighlightAtomMap_
Definition DrawMolMCH.h:78
DrawMolMCH(const DrawMol &)=delete
DrawMolMCH & operator=(const DrawMol &)=delete
const std::map< int, std::vector< DrawColour > > & mcHighlightBondMap_
Definition DrawMolMCH.h:79
void makeBondHighlights(std::vector< std::unique_ptr< DrawShape > > &bondHighlights)
void makeAtomHighlights(std::vector< std::unique_ptr< DrawShape > > &atomHighlights)
DrawMolMCH & operator=(DrawMol &&)=delete
void fixHighlightJoinProblems(std::vector< std::unique_ptr< DrawShape > > &atomHighlights, std::vector< std::unique_ptr< DrawShape > > &bondHighlights)
DrawMolMCH(const ROMol &mol, const std::string &legend, int width, int height, MolDrawOptions &drawOptions, DrawText &textDrawer, const std::map< int, std::vector< DrawColour > > &highlight_atom_map, const std::map< int, std::vector< DrawColour > > &highlight_bond_map, const std::map< int, double > &highlight_radii, const std::map< int, int > &highlight_linewidth_multipliers, int confId=-1)
void adjustLineEndForHighlight(int at_idx, Point2D p1, Point2D &p2) const
void extractHighlights(double scale) override
const std::map< int, int > & highlightLinewidthMultipliers_
Definition DrawMolMCH.h:80
void calcSymbolEllipse(unsigned int atomIdx, Point2D &centre, double &xradius, double &yradius) const
void adjustLineEndForEllipse(const Point2D &centre, double xradius, double yradius, Point2D p1, Point2D &p2)
Std stuff.
bool rdvalue_is(const RDValue_cast_t)