Loading...
Searching...
No Matches
AtomSymbol.h
Go to the documentation of this file.
//
// Copyright (C) 2021-2022 David Cosgrove and other RDKit contributors
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
// Original author: David Cosgrove (CozChemIx Limited)
//
// This class is a helper class used by MolDraw2D to draw an ROMol.
// It is not part of the public API and is not intended to be used except
// by MolDraw2D.
// It holds the information needed to draw an atom symbol, including
// all the extra bits like isotope labels.
#ifndef RDKIT_ATOMSYMBOL_H
#define RDKIT_ATOMSYMBOL_H
#include <string>
#include <GraphMol/MolDraw2D/DrawText.h>
#include <GraphMol/MolDraw2D/MolDraw2DHelpers.h>
namespace RDKit {
class MolDraw2D;
namespace MolDraw2D_detail {
class AtomSymbol {
public:
~AtomSymbol() = default;
/*!
*
* @param symbol : the full symbol
* @param atIdx : index of atom that this is the symbol of
* @param orient : text orientation (up, down, left, right)
* @param cds : coords for symbol
* @param colour : colour for symbol
* @param textDrawer : instance of DrawText to get the character sizes
* etc.
*/
AtomSymbol(const std::string &symbol, int atIdx, OrientType orient,
const Point2D &cds, const DrawColour &colour,
DrawText &textDrawer);
AtomSymbol(const AtomSymbol &) = delete;
AtomSymbol(AtomSymbol &&) = delete;
AtomSymbol &operator=(const AtomSymbol &) = delete;
AtomSymbol &operator=(AtomSymbol &&) = delete;
std::string symbol_;
int atIdx_;
OrientType orient_;
Point2D cds_;
DrawColour colour_;
DrawText &textDrawer_;
std::vector<std::shared_ptr<StringRect>> rects_;
std::vector<TextDrawType> drawModes_;
std::vector<char> drawChars_;
// expects xmin etc to be initialised to something sensible.
void findExtremes(double &xmin, double &xmax, double &ymin,
double &ymax) const;
// scaleFactor moves the cds_, but the fontScaleFactor changes rects_, because
// we might be scaling the font differently from the drawing as a whole.
void scale(const Point2D &scaleFactor);
void move(const Point2D &trans);
void recalculateRects();
void draw(MolDraw2D &molDrawer) const;
bool doesRectClash(const StringRect &rect, double padding) const;
// Because a colon is a lot shorter than other characters, there are cases,
// such as rxn_test1_2 in rxn_test1.cpp, where a vertical bond can slip
// between the atom symbol and the atom map (C:8 in that case) which looks
// a bit pants. This stretches the colon to be the same height as the
// smaller of the chars on either side.
void adjustColons();
// this is for debugging almost always.
void drawRects(MolDraw2D &molDrawer) const;
};
} // namespace MolDraw2D_detail
} // namespace RDKit
#endif // RDKIT_ATOMSYMBOL_H
DrawText.h
MolDraw2DHelpers.h
RDGeom::Point2D
Definition point.h:284
RDKit::MolDraw2D_detail::AtomSymbol::scale
void scale(const Point2D &scaleFactor)
RDKit::MolDraw2D_detail::AtomSymbol::rects_
std::vector< std::shared_ptr< StringRect > > rects_
Definition AtomSymbol.h:62
RDKit::MolDraw2D_detail::AtomSymbol::doesRectClash
bool doesRectClash(const StringRect &rect, double padding) const
RDKit::MolDraw2D_detail::AtomSymbol::textDrawer_
DrawText & textDrawer_
Definition AtomSymbol.h:60
RDKit::MolDraw2D_detail::AtomSymbol::AtomSymbol
AtomSymbol(AtomSymbol &&)=delete
RDKit::MolDraw2D_detail::AtomSymbol::operator=
AtomSymbol & operator=(AtomSymbol &&)=delete
RDKit::MolDraw2D_detail::AtomSymbol::cds_
Point2D cds_
Definition AtomSymbol.h:58
RDKit::MolDraw2D_detail::AtomSymbol::~AtomSymbol
~AtomSymbol()=default
RDKit::MolDraw2D_detail::AtomSymbol::recalculateRects
void recalculateRects()
RDKit::MolDraw2D_detail::AtomSymbol::move
void move(const Point2D &trans)
RDKit::MolDraw2D_detail::AtomSymbol::atIdx_
int atIdx_
Definition AtomSymbol.h:56
RDKit::MolDraw2D_detail::AtomSymbol::drawModes_
std::vector< TextDrawType > drawModes_
Definition AtomSymbol.h:63
RDKit::MolDraw2D_detail::AtomSymbol::operator=
AtomSymbol & operator=(const AtomSymbol &)=delete
RDKit::MolDraw2D_detail::AtomSymbol::AtomSymbol
AtomSymbol(const std::string &symbol, int atIdx, OrientType orient, const Point2D &cds, const DrawColour &colour, DrawText &textDrawer)
RDKit::MolDraw2D_detail::AtomSymbol::drawRects
void drawRects(MolDraw2D &molDrawer) const
RDKit::MolDraw2D_detail::AtomSymbol::colour_
DrawColour colour_
Definition AtomSymbol.h:59
RDKit::MolDraw2D_detail::AtomSymbol::draw
void draw(MolDraw2D &molDrawer) const
RDKit::MolDraw2D_detail::AtomSymbol::findExtremes
void findExtremes(double &xmin, double &xmax, double &ymin, double &ymax) const
RDKit::MolDraw2D_detail::AtomSymbol::AtomSymbol
AtomSymbol(const AtomSymbol &)=delete
RDKit::MolDraw2D_detail::AtomSymbol::drawChars_
std::vector< char > drawChars_
Definition AtomSymbol.h:64
RDKit::MolDraw2D_detail::AtomSymbol::symbol_
std::string symbol_
Definition AtomSymbol.h:55
RDKit::MolDraw2D_detail::AtomSymbol::orient_
OrientType orient_
Definition AtomSymbol.h:57
RDKit::MolDraw2D_detail::AtomSymbol::adjustColons
void adjustColons()
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
symbol
static const char * symbol[119]
Definition mf.h:257
RDKit::MolDraw2D_detail
Definition AtomSymbol.h:30
RDKit::MolDraw2D_detail::OrientType
OrientType
Definition MolDraw2DHelpers.h:26
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::DrawColour
Definition MolDraw2DHelpers.h:40
RDKit::MolDraw2D_detail::StringRect
Definition StringRect.h:24