RDKit: DrawMolMCHLasso.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
DrawMolMCHLasso.h
Go to the documentation of this file.
1//
2// Copyright (C) 2023 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#ifndef DRAWMOLMCHLASSO_H
11#define DRAWMOLMCHLASSO_H
12
13#include <GraphMol/MolDraw2D/DrawMolMCH.h>
14
15namespace RDKit {
16namespace MolDraw2D_detail {
17
18// Struct to hold a pair of lines that make up part of the
19// lasso. Each atom in the lasso will have one for each
20// of its bonds that are in the lasso. The angles are
21// subtended by the line ends at the atom centres relative
22// to the x axis. The radius is also the distance from
23// the nearest end of each line ot the atom.
24 struct LinePair {
25 DrawShapeSimpleLine *line1;
26 DrawShapeSimpleLine *line2;
27 double angle1;
28 double angle2;
29 double radius;
30 int atom;
31};
32
33 class DrawMolMCHLasso : public DrawMolMCH {
34 public:
35 /*!
36 Make a DrawMol that does multi-coloured highlights. Both atoms and
37 bonds can have more than 1 highlight. There's no maximum although more
38 than 4 is very cluttered.
39 \param mol : the molecule to draw
40 \param legend : the legend (to be drawn under the molecule)
41 \param width : width (in pixels) of the rendering
42 set this to -1 to have the canvas size set automatically
43 \param height : height (in pixels) of the rendering
44 set this to -1 to have the canvas size set automatically
45 \param drawOptions : a MolDrawOptions object from the owning MolDraw2D
46 \param textDrawer : a DrawText object from the owning MolDraw2D
47 \param highlight_atom_map : indexed on atom idx, the colours to be used to
48 highlight atoms. Not all atoms need to be mentioned.
49 \param highlight_bond_map : If this is empty, then the lassos will be between
50 all bonded atoms in the highlight_atom_map, in
51 the appropriate colours. If it is given, the lasso
52 will be in more than one part if there is a bond
53 between 2 highlighted atoms that isn't in the
54 highlight_bond_map. The colours in
55 highlight_bond_map will be NOT used for the lines
56 between the atoms - the lasso will be one colour,
57 taken from the atoms.
58 \param highlightRadii : ignored in this molecule representation.
59 \param highlight_linewidth_multipliers : ignored in this molecule
60 representation. \param confId : (optional) conformer ID to be used for
61 atomic coordinates
62 */
63 DrawMolMCHLasso(
64 const ROMol &mol, const std::string &legend, int width, int height,
65 MolDrawOptions &drawOptions, DrawText &textDrawer,
66 const std::map<int, std::vector<DrawColour>> &highlight_atom_map,
67 const std::map<int, std::vector<DrawColour>> &highlight_bond_map,
68 const std::map<int, double> &highlight_radii,
69 const std::map<int, int> &highlight_linewidth_multipliers,
70 int confId = -1);
71 DrawMolMCHLasso(const DrawMol &) = delete;
72 DrawMolMCHLasso(DrawMol &&) = delete;
73 DrawMolMCHLasso &operator=(const DrawMol &) = delete;
74 DrawMolMCHLasso &operator=(DrawMol &&) = delete;
75
76 void extractHighlights(double scale) override;
77 void extractMCHighlights() override;
78 // turn mcHighlightAtomMap_ into a mapping of vectors of atoms of a particular
79 // colour, indexed by the colour.
80 void extractAtomColourLists(std::vector<DrawColour> &colours,
81 std::vector<std::vector<int>> &colourAtoms,
82 std::vector<std::vector<int>> &colourLists) const;
83 void drawLasso(size_t lassoNum, const DrawColour &col,
84 const std::vector<int> &colAtoms);
85 void extractBondLines(
86 size_t lassoNum, const DrawColour &col, const std::vector<int> &colAtoms,
87 std::vector<std::unique_ptr<DrawShapeSimpleLine>> &lines,
88 std::vector<std::vector<LinePair>> &atomLines) const;
89 void extractAtomArcs(std::vector<std::vector<LinePair>> &atomLines,
90 std::vector<std::unique_ptr<DrawShapeArc>> &arcs) const;
91 void addNoLineArcs(
92 const std::vector<int> &colAtoms, size_t lassoNum,
93 const RDKit::DrawColour &col,
94 const std::vector<std::unique_ptr<DrawShapeSimpleLine>> &lines,
95 std::vector<std::unique_ptr<DrawShapeArc>> &arcs) const;
96 void makeIntersectingArcs(
97 const std::vector<std::vector<unsigned int>> &intersects, int lassoNum,
98 const RDKit::DrawColour &col,
99 std::vector<std::unique_ptr<DrawShapeArc>> &currArcs,
100 std::vector<DrawShapeArc *> &arcs) const;
101 // Put the start points of each pair of atoms in order so that going in
102 // an anti-clockwise direction the bond that the lines straddle is in
103 // between them such that the arc between the first and second is always
104 // the bit that isn't drawn. And then order the pairs so that the bonds
105 // are moving round in an anti-clockwise direction.
106 void orderAtomLines(std::vector<std::vector<LinePair>> &atomLines) const;
107};
108} // namespace MolDraw2D_detail
109} // namespace RDKit
110
111#endif // DRAWMOLMCHLASSO_H
DrawMolMCH.h
RDKit::MolDraw2D_detail::DrawMolMCHLasso::extractMCHighlights
void extractMCHighlights() override
RDKit::MolDraw2D_detail::DrawMolMCHLasso::operator=
DrawMolMCHLasso & operator=(DrawMol &&)=delete
RDKit::MolDraw2D_detail::DrawMolMCHLasso::orderAtomLines
void orderAtomLines(std::vector< std::vector< LinePair > > &atomLines) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::addNoLineArcs
void addNoLineArcs(const std::vector< int > &colAtoms, size_t lassoNum, const RDKit::DrawColour &col, const std::vector< std::unique_ptr< DrawShapeSimpleLine > > &lines, std::vector< std::unique_ptr< DrawShapeArc > > &arcs) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::makeIntersectingArcs
void makeIntersectingArcs(const std::vector< std::vector< unsigned int > > &intersects, int lassoNum, const RDKit::DrawColour &col, std::vector< std::unique_ptr< DrawShapeArc > > &currArcs, std::vector< DrawShapeArc * > &arcs) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::DrawMolMCHLasso
DrawMolMCHLasso(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)
RDKit::MolDraw2D_detail::DrawMolMCHLasso::DrawMolMCHLasso
DrawMolMCHLasso(const DrawMol &)=delete
RDKit::MolDraw2D_detail::DrawMolMCHLasso::operator=
DrawMolMCHLasso & operator=(const DrawMol &)=delete
RDKit::MolDraw2D_detail::DrawMolMCHLasso::DrawMolMCHLasso
DrawMolMCHLasso(DrawMol &&)=delete
RDKit::MolDraw2D_detail::DrawMolMCHLasso::drawLasso
void drawLasso(size_t lassoNum, const DrawColour &col, const std::vector< int > &colAtoms)
RDKit::MolDraw2D_detail::DrawMolMCHLasso::extractAtomColourLists
void extractAtomColourLists(std::vector< DrawColour > &colours, std::vector< std::vector< int > > &colourAtoms, std::vector< std::vector< int > > &colourLists) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::extractAtomArcs
void extractAtomArcs(std::vector< std::vector< LinePair > > &atomLines, std::vector< std::unique_ptr< DrawShapeArc > > &arcs) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::extractBondLines
void extractBondLines(size_t lassoNum, const DrawColour &col, const std::vector< int > &colAtoms, std::vector< std::unique_ptr< DrawShapeSimpleLine > > &lines, std::vector< std::vector< LinePair > > &atomLines) const
RDKit::MolDraw2D_detail::DrawMolMCHLasso::extractHighlights
void extractHighlights(double scale) override
RDKit::MolDraw2D_detail::DrawMolMCH::DrawMolMCH
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)
RDKit::MolDraw2D_detail::DrawMol
Definition DrawMol.h:39
RDKit::MolDraw2D_detail::DrawShapeSimpleLine
Definition DrawShape.h:107
RDKit::MolDraw2D_detail::DrawText
Definition DrawText.h:46
RDKit::ROMol
Definition ROMol.h:199
RDKit::MolDraw2D_detail
Definition AtomSymbol.h:30
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::DrawColour
Definition MolDraw2DHelpers.h:40
RDKit::MolDraw2D_detail::LinePair
Definition DrawMolMCHLasso.h:24
RDKit::MolDraw2D_detail::LinePair::radius
double radius
Definition DrawMolMCHLasso.h:29
RDKit::MolDraw2D_detail::LinePair::line1
DrawShapeSimpleLine * line1
Definition DrawMolMCHLasso.h:25
RDKit::MolDraw2D_detail::LinePair::atom
int atom
Definition DrawMolMCHLasso.h:30
RDKit::MolDraw2D_detail::LinePair::angle2
double angle2
Definition DrawMolMCHLasso.h:28
RDKit::MolDraw2D_detail::LinePair::angle1
double angle1
Definition DrawMolMCHLasso.h:27
RDKit::MolDraw2D_detail::LinePair::line2
DrawShapeSimpleLine * line2
Definition DrawMolMCHLasso.h:26
RDKit::MolDrawOptions
Definition MolDraw2DHelpers.h:174