RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
AtomSymbol.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 is a helper class used by MolDraw2D to draw an ROMol.
13// It is not part of the public API and is not intended to be used except
14// by MolDraw2D.
15// It holds the information needed to draw an atom symbol, including
16// all the extra bits like isotope labels.
17
18#ifndef RDKIT_ATOMSYMBOL_H
19#define RDKIT_ATOMSYMBOL_H
20
21#include <string>
22
25
26namespace RDKit {
27
28class MolDraw2D;
29
30namespace MolDraw2D_detail {
31
33 public:
34 virtual ~AtomSymbol() = default;
35
36 /*!
37 *
38 * @param symbol : the full symbol
39 * @param orient : text orientation (up, down, left, right)
40 * @param textDrawer : instance of DrawText to get the character sizes
41 * etc.
42 */
43 AtomSymbol(const std::string &symbol, int atIdx, OrientType orient,
44 const Point2D &cds, const DrawColour &colour,
46
47 AtomSymbol(const AtomSymbol &) = delete;
48 AtomSymbol(AtomSymbol &&) = delete;
49 AtomSymbol &operator=(const AtomSymbol &) = delete;
51
52 std::string symbol_;
53 int atIdx_;
58
59 std::vector<std::shared_ptr<StringRect>> rects_;
60 std::vector<TextDrawType> drawModes_;
61 std::vector<char> drawChars_;
62
63 // expects xmin etc to be initialised to something sensible.
64 virtual void findExtremes(double &xmin, double &xmax, double &ymin,
65 double &ymax) const;
66 // scaleFactor moves the cds_, but the fontScaleFactor changes rects_, because
67 // we might be scaling the font differently from the drawing as a whole.
68 virtual void scale(const Point2D &scaleFactor);
69 virtual void move(const Point2D &trans);
70 void draw(MolDraw2D &molDrawer) const;
71 bool doesRectClash(const StringRect &rect, double padding) const;
72 // Because a colon is a lot shorter than other characters, there are cases,
73 // such as rxn_test1_2 in rxn_test1.cpp, where a vertical bond can slip
74 // between the atom symbol and the atom map (C:8 in that case) which looks
75 // a bit pants. This stretches the colon to be the same height as the
76 // smaller of the chars on either side.
78
79 // this is for debugging almost always.
81};
82
83} // namespace MolDraw2D_detail
84} // namespace RDKit
85
86#endif // RDKIT_ATOMSYMBOL_H
virtual void findExtremes(double &xmin, double &xmax, double &ymin, double &ymax) const
std::vector< std::shared_ptr< StringRect > > rects_
Definition AtomSymbol.h:59
bool doesRectClash(const StringRect &rect, double padding) const
AtomSymbol(AtomSymbol &&)=delete
virtual void move(const Point2D &trans)
AtomSymbol & operator=(AtomSymbol &&)=delete
std::vector< TextDrawType > drawModes_
Definition AtomSymbol.h:60
AtomSymbol & operator=(const AtomSymbol &)=delete
AtomSymbol(const std::string &symbol, int atIdx, OrientType orient, const Point2D &cds, const DrawColour &colour, DrawText &textDrawer)
void drawRects(MolDraw2D &molDrawer) const
void draw(MolDraw2D &molDrawer) const
virtual void scale(const Point2D &scaleFactor)
AtomSymbol(const AtomSymbol &)=delete
MolDraw2D is the base class for doing 2D renderings of molecules.
Definition MolDraw2D.h:47
static const char * symbol[119]
Definition mf.h:257
Std stuff.
bool rdvalue_is(const RDValue_cast_t)