RDKit
Open-source cheminformatics and machine learning.
DrawAnnotation.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 used by DrawMol to draw annotation (atom and bond
13 // notes, for example) onto the molecule.
14 // It is not part of the public API.
15 
16 #ifndef RDKIT_DRAWANNOTATION_H
17 #define RDKIT_DRAWANNOTATION_H
18 
19 #include <Geometry/point.h>
22 
23 namespace RDKit {
24 
25 class MolDraw2D;
26 
27 namespace MolDraw2D_detail {
28 
30  public:
31  ~DrawAnnotation() = default;
32 
33  DrawAnnotation(const std::string &note, const TextAlignType &align,
34  const std::string &cls, double relFontScale,
35  const Point2D &pos, const DrawColour &colour,
36  DrawText &textDrawer);
37  DrawAnnotation(const DrawAnnotation &) = delete;
41 
42  // expects xmin etc to be initialised to something sensible.
43  void findExtremes(double &xmin, double &xmax, double &ymin, double &ymax,
44  double padding = 0.0) const;
45  void getDimensions(double &width, double &height) const;
46  void extractRects();
47  void draw(MolDraw2D &molDrawer) const;
48  // this is for debugging almost always.
49  void drawRects(MolDraw2D &molDrawer) const;
50  void scale(const Point2D &scaleFactor);
51  void move(const Point2D &trans);
52  bool doesRectClash(const StringRect &rect, double padding) const;
53 
54  std::string text_;
56  std::string class_; // for SVG output, most likely
57  double fontScale_; // fontScale to use
59  Point2D pos_ = Point2D(0.0, 0.0);
60  DrawColour colour_ = DrawColour(0.0, 0.0, 0.0, 0.0);
61  std::vector<std::shared_ptr<StringRect>> rects_;
62 };
63 
64 } // namespace MolDraw2D_detail
65 } // namespace RDKit
66 #endif // RDKIT_DRAWANNOTATION_H
DrawAnnotation(const DrawAnnotation &)=delete
DrawAnnotation & operator=(const DrawAnnotation &)=delete
DrawAnnotation(DrawAnnotation &&)=delete
DrawAnnotation(const std::string &note, const TextAlignType &align, const std::string &cls, double relFontScale, const Point2D &pos, const DrawColour &colour, DrawText &textDrawer)
void scale(const Point2D &scaleFactor)
bool doesRectClash(const StringRect &rect, double padding) const
DrawAnnotation & operator=(DrawAnnotation &&)=delete
void move(const Point2D &trans)
void getDimensions(double &width, double &height) const
void drawRects(MolDraw2D &molDrawer) const
void draw(MolDraw2D &molDrawer) const
void findExtremes(double &xmin, double &xmax, double &ymin, double &ymax, double padding=0.0) const
std::vector< std::shared_ptr< StringRect > > rects_
MolDraw2D is the base class for doing 2D renderings of molecules.
Definition: MolDraw2D.h:47
Std stuff.
Definition: Abbreviations.h:18