RDKit: DrawAnnotation.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
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>
20#include <GraphMol/MolDraw2D/DrawText.h>
21#include <GraphMol/MolDraw2D/MolDraw2DHelpers.h>
22
23namespace RDKit {
24
25class MolDraw2D;
26
27namespace MolDraw2D_detail {
28
29 class DrawAnnotation {
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;
38 DrawAnnotation(DrawAnnotation &&) = delete;
39 DrawAnnotation &operator=(const DrawAnnotation &) = delete;
40 DrawAnnotation &operator=(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_;
55 TextAlignType align_;
56 std::string class_; // for SVG output, most likely
57 double fontScale_; // fontScale to use
58 DrawText &textDrawer_;
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
DrawText.h
MolDraw2DHelpers.h
RDGeom::Point2D
Definition point.h:284
RDKit::MolDraw2D_detail::DrawAnnotation::DrawAnnotation
DrawAnnotation(const DrawAnnotation &)=delete
RDKit::MolDraw2D_detail::DrawAnnotation::operator=
DrawAnnotation & operator=(DrawAnnotation &&)=delete
RDKit::MolDraw2D_detail::DrawAnnotation::colour_
DrawColour colour_
Definition DrawAnnotation.h:60
RDKit::MolDraw2D_detail::DrawAnnotation::textDrawer_
DrawText & textDrawer_
Definition DrawAnnotation.h:58
RDKit::MolDraw2D_detail::DrawAnnotation::DrawAnnotation
DrawAnnotation(DrawAnnotation &&)=delete
RDKit::MolDraw2D_detail::DrawAnnotation::pos_
Point2D pos_
Definition DrawAnnotation.h:59
RDKit::MolDraw2D_detail::DrawAnnotation::DrawAnnotation
DrawAnnotation(const std::string &note, const TextAlignType &align, const std::string &cls, double relFontScale, const Point2D &pos, const DrawColour &colour, DrawText &textDrawer)
RDKit::MolDraw2D_detail::DrawAnnotation::scale
void scale(const Point2D &scaleFactor)
RDKit::MolDraw2D_detail::DrawAnnotation::doesRectClash
bool doesRectClash(const StringRect &rect, double padding) const
RDKit::MolDraw2D_detail::DrawAnnotation::~DrawAnnotation
~DrawAnnotation()=default
RDKit::MolDraw2D_detail::DrawAnnotation::extractRects
void extractRects()
RDKit::MolDraw2D_detail::DrawAnnotation::move
void move(const Point2D &trans)
RDKit::MolDraw2D_detail::DrawAnnotation::getDimensions
void getDimensions(double &width, double &height) const
RDKit::MolDraw2D_detail::DrawAnnotation::fontScale_
double fontScale_
Definition DrawAnnotation.h:57
RDKit::MolDraw2D_detail::DrawAnnotation::class_
std::string class_
Definition DrawAnnotation.h:56
RDKit::MolDraw2D_detail::DrawAnnotation::align_
TextAlignType align_
Definition DrawAnnotation.h:55
RDKit::MolDraw2D_detail::DrawAnnotation::drawRects
void drawRects(MolDraw2D &molDrawer) const
RDKit::MolDraw2D_detail::DrawAnnotation::text_
std::string text_
Definition DrawAnnotation.h:54
RDKit::MolDraw2D_detail::DrawAnnotation::draw
void draw(MolDraw2D &molDrawer) const
RDKit::MolDraw2D_detail::DrawAnnotation::operator=
DrawAnnotation & operator=(const DrawAnnotation &)=delete
RDKit::MolDraw2D_detail::DrawAnnotation::findExtremes
void findExtremes(double &xmin, double &xmax, double &ymin, double &ymax, double padding=0.0) const
RDKit::MolDraw2D_detail::DrawAnnotation::rects_
std::vector< std::shared_ptr< StringRect > > rects_
Definition DrawAnnotation.h:61
RDKit::MolDraw2D_detail::DrawText
Definition DrawText.h:46
RDKit::MolDraw2D
MolDraw2D is the base class for doing 2D renderings of molecules.
Definition MolDraw2D.h:47
RDKit::MolDraw2D_detail
Definition AtomSymbol.h:30
RDKit::MolDraw2D_detail::TextAlignType
TextAlignType
Definition MolDraw2DHelpers.h:33
RDKit
Std stuff.
Definition Abbreviations.h:19
point.h
RDKit::DrawColour
Definition MolDraw2DHelpers.h:40
RDKit::MolDraw2D_detail::StringRect
Definition StringRect.h:24