16 #ifndef RDKIT_DRAWMOL_H
17 #define RDKIT_DRAWMOL_H
37 namespace MolDraw2D_detail {
67 DrawMol(
const ROMol &mol,
const std::string &legend,
int width,
int height,
69 const std::vector<int> *highlightAtoms =
nullptr,
70 const std::vector<int> *highlightBonds =
nullptr,
71 const std::map<int, DrawColour> *highlightAtomMap =
nullptr,
72 const std::map<int, DrawColour> *highlightBondMap =
nullptr,
73 const std::vector<std::pair<DrawColour, DrawColour>> *bondColours =
75 const std::map<int, double> *highlight_radii =
nullptr,
76 bool includeAnnotations =
true,
int confId = -1,
77 bool isReactionMol =
false);
95 DrawText &textDrawer,
double xmin,
double xmax,
double ymin,
96 double ymax,
double scale,
double fontscale);
140 const Atom &atom)
const;
155 const std::pair<DrawColour, DrawColour> &cols);
157 const std::pair<DrawColour, DrawColour> &cols);
159 const std::pair<DrawColour, DrawColour> &cols);
162 const std::pair<DrawColour, DrawColour> &cols);
169 int atom2Idx,
int bondIdx,
const DashPattern &dashPattern);
193 const Point2D &toCentre)
const;
204 void setScale(
double newScale,
double newFontScale,
205 bool ignoreFontLimits =
true);
219 const Point2D *toCentre =
nullptr);
223 const Point2D *toCentre =
nullptr)
const;
242 std::vector<std::unique_ptr<DrawShape>>
bonds_;
246 std::vector<std::pair<std::string, OrientType>>
atomSyms_;
250 std::vector<std::unique_ptr<DrawAnnotation>>
legends_;
251 std::vector<std::tuple<StringRect, OrientType, int>>
radicals_;
277 const std::vector<int> &atomicNums,
278 const std::vector<int> *highlightAtoms,
279 const std::map<int, DrawColour> *highlightMap);
284 const std::map<int, int> *highlight_linewidth_multipliers);
287 const std::vector<Point2D> &at_cds,
Point2D &l1s,
290 const std::vector<Point2D> &at_cds,
Point2D &l1s,
296 const Point2D &cds2,
const std::vector<Point2D> &at_cds);
298 const std::vector<Point2D> &at_cds);
302 const Point2D &end2,
double padding,
303 const std::vector<std::shared_ptr<StringRect>> &rects,
Point2D &moveEnd);
305 const std::vector<std::tuple<StringRect, OrientType, int>> &radicals,
306 double &xmin,
double &xmax,
double &ymin,
double &ymax);
308 double &xmin,
double &xmax,
double &ymin,
double &ymax);
310 const std::vector<int> &highlight_atoms,
311 std::vector<int> &highlight_bonds);
The class for representing atoms.
class for representing a bond
void newBondLine(const Point2D &pt1, const Point2D &pt2, const DrawColour &col1, const DrawColour &col2, int atom1Idx, int atom2Idx, int bondIdx, const DashPattern &dashPattern)
std::pair< std::string, OrientType > getAtomSymbolAndOrientation(const Atom &atom) const
void makeAtomEllipseHighlights(int lineWidth)
void extractAttachments()
void extractVariableBonds()
Point2D getDrawCoords(const Point2D &atCds) const
void makeBondHighlightLines(int lineWidth)
void makeWavyBond(Bond *bond, const std::pair< DrawColour, DrawColour > &cols)
void tagAtomsWithCoords()
std::unique_ptr< RWMol > drawMol_
std::map< int, DrawColour > highlightAtomMap_
void calcMeanBondLength()
void setTransformation(const DrawMol &sourceMol)
std::vector< std::unique_ptr< AtomSymbol > > atomLabels_
std::string getAtomSymbol(const Atom &atom, OrientType orientation) const
std::map< int, double > highlightRadii_
void extractCloseContacts()
void shrinkToFit(bool withPadding=true)
std::map< int, DrawColour > highlightBondMap_
std::vector< std::pair< std::string, OrientType > > atomSyms_
virtual ~DrawMol()=default
void drawRadicals(MolDraw2D &drawer) const
void setScale(double newScale, double newFontScale, bool ignoreFontLimits=true)
std::vector< std::unique_ptr< DrawAnnotation > > annotations_
Point2D getAtomCoords(int atnum) const
DrawMol & operator=(const DrawMol &)=delete
std::vector< int > highlightAtoms_
DrawMol(const DrawMol &)=delete
Point2D transformPoint(const Point2D &pt, const Point2D *trans=nullptr, Point2D *scale=nullptr, const Point2D *toCentre=nullptr) const
void makeWedgedBond(Bond *bond, const std::pair< DrawColour, DrawColour > &cols)
std::vector< std::unique_ptr< DrawShape > > preShapes_
std::pair< DrawColour, DrawColour > getBondColours(Bond *bond)
void finishCreateDrawObjects()
std::vector< std::pair< DrawColour, DrawColour > > bondColours_
void setOffsets(double xOffset, double yOffset)
std::vector< std::unique_ptr< DrawAnnotation > > legends_
DrawMol & operator=(DrawMol &&)=delete
void makeStandardBond(Bond *bond, double doubleBondOffset)
void makeTripleBondLines(Bond *bond, double doubleBondOffset, const std::pair< DrawColour, DrawColour > &cols)
Point2D getAtomCoords(const Point2D &screenCds) const
void partitionForLegend()
void adjustBondEndsForLabels(int begAtIdx, int endAtIdx, Point2D &begCds, Point2D &endCds)
double getNoteStartAngle(const Atom *atom) const
DrawMol(const ROMol &mol, const std::string &legend, int width, int height, const MolDrawOptions &drawOptions, DrawText &textDrawer, const std::vector< int > *highlightAtoms=nullptr, const std::vector< int > *highlightBonds=nullptr, const std::map< int, DrawColour > *highlightAtomMap=nullptr, const std::map< int, DrawColour > *highlightBondMap=nullptr, const std::vector< std::pair< DrawColour, DrawColour >> *bondColours=nullptr, const std::map< int, double > *highlight_radii=nullptr, bool includeAnnotations=true, int confId=-1, bool isReactionMol=false)
void makeDativeBond(Bond *bond, const std::pair< DrawColour, DrawColour > &cols)
const MolDrawOptions & drawOptions_
void makeAtomCircleHighlights()
std::vector< std::tuple< StringRect, OrientType, int > > radicals_
void makeQueryBond(Bond *bond, double doubleBondOffset)
std::vector< std::unique_ptr< DrawShape > > postShapes_
std::vector< Point2D > atCds_
int doesRectClash(const StringRect &rect, double padding) const
virtual void extractHighlights()
std::vector< std::unique_ptr< DrawShape > > highlights_
std::vector< int > atomicNums_
std::vector< int > highlightBonds_
void draw(MolDraw2D &drawer) const
void transformAll(const Point2D *trans=nullptr, Point2D *scale=nullptr, const Point2D *toCentre=nullptr)
void getDrawTransformers(Point2D &trans, Point2D &scale, Point2D &toCentre) const
OrientType calcRadicalRect(const Atom *atom, StringRect &rad_rect) const
void makeZeroBond(Bond *bond, const std::pair< DrawColour, DrawColour > &cols, const DashPattern &dashPattern)
std::vector< std::unique_ptr< DrawShape > > bonds_
void calcMolNotePosition(const std::vector< Point2D > atCds, DrawAnnotation &annot) const
int doesNoteClash(const DrawAnnotation &annot) const
void extractAtomSymbols()
void calcAnnotationPosition(const Atom *atom, DrawAnnotation &annot) const
void calcAnnotationPosition(const Bond *bond, DrawAnnotation &annot) const
Point2D getDrawCoords(int atnum) const
OrientType getAtomOrientation(const Atom &atom) const
Point2D getDrawCoords(const Point2D &atCds, const Point2D &trans, const Point2D &scaleFactor, const Point2D &toCentre) const
DrawMol(DrawMol &&)=delete
void makeDoubleBondLines(Bond *bond, double doubleBondOffset, const std::pair< DrawColour, DrawColour > &cols)
double getFontScale() const
void makeContinuousHighlights()
void initDrawMolecule(const ROMol &mol)
DrawMol(int width, int height, const MolDrawOptions &drawOptions, DrawText &textDrawer, double xmin, double xmax, double ymin, double ymax, double scale, double fontscale)
void changeToDrawCoords()
MolDraw2D is the base class for doing 2D renderings of molecules.
RWMol is a molecule class that is intended to be edited.
Point2D calcPerpendicular(const Point2D &cds1, const Point2D &cds2)
Point2D bondInsideRing(const ROMol &mol, const Bond &bond, const Point2D &cds1, const Point2D &cds2, const std::vector< Point2D > &at_cds)
Point2D calcInnerPerpendicular(const Point2D &cds1, const Point2D &cds2, const Point2D &cds3)
void findRectExtremes(const StringRect &rect, const TextAlignType &align, double &xmin, double &xmax, double &ymin, double &ymax)
bool isLinearAtom(const Atom &atom, const std::vector< Point2D > &atCds)
void adjustBondEndForString(const Point2D &end2, double padding, const std::vector< std::shared_ptr< StringRect >> &rects, Point2D &moveEnd)
void prepareStereoGroups(RWMol &mol)
int getHighlightBondWidth(const MolDrawOptions &drawOptions, int bond_idx, const std::map< int, int > *highlight_linewidth_multipliers)
void findRadicalExtremes(const std::vector< std::tuple< StringRect, OrientType, int >> &radicals, double &xmin, double &xmax, double &ymin, double &ymax)
void centerMolForDrawing(RWMol &mol, int confId=1)
DrawColour getColourByAtomicNum(int atomicNum, const MolDrawOptions &drawOptions)
Point2D bondInsideDoubleBond(const ROMol &mol, const Bond &bond, const std::vector< Point2D > &at_cds)
DrawColour getColour(int atom_idx, const MolDrawOptions &drawOptions, const std::vector< int > &atomicNums, const std::vector< int > *highlightAtoms, const std::map< int, DrawColour > *highlightMap)
void getBondHighlightsForAtoms(const ROMol &mol, const std::vector< int > &highlight_atoms, std::vector< int > &highlight_bonds)
void calcDoubleBondLines(const ROMol &mol, double offset, const Bond &bond, const std::vector< Point2D > &at_cds, Point2D &l1s, Point2D &l1f, Point2D &l2s, Point2D &l2f)
std::string getAtomListText(const Atom &atom)
void calcTripleBondLines(double offset, const Bond &bond, const std::vector< Point2D > &at_cds, Point2D &l1s, Point2D &l1f, Point2D &l2s, Point2D &l2f)
std::vector< double > DashPattern