25#ifndef RDKITMOLDRAW2D_H
26#define RDKITMOLDRAW2D_H
41namespace MolDraw2D_detail {
62 MolDraw2D(
int width,
int height,
int panelWidth,
int panelHeight);
89 const ROMol &mol,
const std::string &legend,
90 const std::vector<int> *highlight_atoms,
91 const std::vector<int> *highlight_bonds,
92 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
93 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
94 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
98 const std::vector<int> *highlight_atoms =
nullptr,
99 const std::map<int, DrawColour> *highlight_map =
nullptr,
100 const std::map<int, double> *highlight_radii =
nullptr,
105 const std::vector<int> *highlight_atoms =
nullptr,
106 const std::map<int, DrawColour> *highlight_map =
nullptr,
107 const std::map<int, double> *highlight_radii =
nullptr,
112 const ROMol &mol,
const std::vector<int> *highlight_atoms,
113 const std::vector<int> *highlight_bonds,
114 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
115 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
116 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
136 const ROMol &mol,
const std::string &legend,
137 const std::map<
int, std::vector<DrawColour>> &highlight_atom_map,
138 const std::map<
int, std::vector<DrawColour>> &highlight_bond_map,
139 const std::map<int, double> &highlight_radii,
140 const std::map<int, int> &highlight_linewidth_multipliers,
170 const std::vector<ROMol *> &mols,
171 const std::vector<std::string> *legends =
nullptr,
172 const std::vector<std::vector<int>> *highlight_atoms =
nullptr,
173 const std::vector<std::vector<int>> *highlight_bonds =
nullptr,
174 const std::vector<std::map<int, DrawColour>> *highlight_atom_maps =
176 const std::vector<std::map<int, DrawColour>> *highlight_bond_maps =
178 const std::vector<std::map<int, double>> *highlight_radii =
nullptr,
179 const std::vector<int> *confIds =
nullptr);
195 const std::vector<DrawColour> *highlightColorsReactants =
nullptr,
196 const std::vector<int> *confIds =
nullptr);
200 const ROMol &mol,
const std::string &legend =
"",
201 const std::vector<int> *highlight_atoms =
nullptr,
202 const std::vector<int> *highlight_bonds =
nullptr,
203 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
204 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
205 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
220 bool rawCoords =
false) = 0;
228 bool rawCoords =
false) = 0;
240 bool rawCoords =
false);
243 const Point2D &cds3,
bool rawCoords =
false);
246 bool rawCoords =
false);
252 double ang2,
bool rawCoords =
false);
255 double ang1,
double ang2,
bool rawCoords =
false);
258 bool rawCoords =
false);
263 unsigned int nSegments = 16,
264 bool rawCoords =
false);
268 unsigned int nSegments = 16,
269 double vertOffset = 0.05,
bool rawCoords =
false);
272 bool asPolygon =
false,
double frac = 0.05,
273 double angle =
M_PI / 6,
275 bool rawCoords =
false);
278 const DrawColour &col,
bool rawCoords =
false);
282 bool rawCoords =
false);
287 bool rawCoords =
false);
313 const std::pair<double, double> &screen_cds)
const;
322 const std::vector<std::pair<std::string, MolDraw2D_detail::OrientType>>
326 int width()
const {
return width_; }
345 int drawHeight()
const {
return panel_height_ - legend_height_; }
355 const ROMol *mol =
nullptr);
384 drawOptions().bondLineWidth = width;
387 virtual double lineWidth()
const {
return drawOptions().bondLineWidth; }
397 double &label_height)
const;
402 double &label_height)
const;
406 const Point2D &cds,
double &x_min,
double &y_min,
407 double &x_max,
double &y_max)
const;
432 activeBndIdx_ = (bnd_idx < 0 ? -1 : bnd_idx);
435 d_activeClass = actClass;
442 bool needs_init_ =
true;
444 unsigned int d_numMetadataEntries = 0;
449 virtual void initDrawing() = 0;
450 virtual void initTextDrawer(
bool noFreetype) = 0;
458 void getReactionDrawMols(
460 const std::vector<DrawColour> *highlightColorsReactants,
461 const std::vector<int> *confIds,
462 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reagents,
463 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &products,
464 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &agents,
468 void makeReactionComponents(
469 std::vector<RDKit::ROMOL_SPTR>
const &bits,
470 const std::vector<int> *confIds,
int heightToUse,
471 std::map<int, DrawColour> &atomColours,
472 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &dms,
473 double &minScale,
double &minFontScale);
476 void makeReactionDrawMol(
477 RWMol &mol,
int confId,
int molHeight,
478 const std::vector<int> &highlightAtoms,
479 const std::vector<int> &highlightBonds,
480 const std::map<int, DrawColour> &highlightAtomMap,
481 const std::map<int, DrawColour> &highlightBondMap,
482 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &mols);
486 void calcReactionOffsets(
487 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reagents,
488 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &products,
489 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &agents,
490 int &plusWidth, std::vector<Point2D> &offsets,
Point2D &arrowBeg,
493 int drawReactionPart(
494 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reactBit,
495 int plusWidth,
int initOffset,
const std::vector<Point2D> &offsets);
498 void findReactionHighlights(
500 const std::vector<DrawColour> *highlightColorsReactants,
501 std::map<int, DrawColour> &atomColours)
const;
503 int width_, height_, panel_width_, panel_height_, legend_height_;
506 bool forceScale_ =
false;
507 bool flexiMode_ =
false;
508 double scale_, fontScale_;
509 int x_offset_, y_offset_;
517 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> drawMols_;
523 std::unique_ptr<MolDraw2D_detail::DrawMol> globalDrawTrans_;
532 void setupTextDrawer();
534 virtual void updateMetadata(
const ROMol &mol,
int confId) {
554 opts.atomColourPalette.clear();
#define RDUNUSED_PARAM(x)
pulls in the core RDKit functionality
This is a class for storing and applying general chemical reactions.
MolDraw2D is the base class for doing 2D renderings of molecules.
virtual void tagAtoms(const ROMol &mol)
void drawMolecule(const ROMol &mol, const std::string &legend, const std::vector< int > *highlight_atoms=nullptr, const std::map< int, DrawColour > *highlight_map=nullptr, const std::map< int, double > *highlight_radii=nullptr, int confId=-1)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setActiveBndIdx(int bnd_idx=-1)
MolDraw2D & operator=(MolDraw2D &&rhs)=delete
void drawMoleculeWithHighlights(const ROMol &mol, const std::string &legend, const std::map< int, std::vector< DrawColour > > &highlight_atom_map, const std::map< int, std::vector< DrawColour > > &highlight_bond_map, const std::map< int, double > &highlight_radii, const std::map< int, int > &highlight_linewidth_multipliers, int confId=-1)
draw molecule with multiple colours allowed per atom.
void setScale(int width, int height, const Point2D &minv, const Point2D &maxv, const ROMol *mol=nullptr)
int panelHeight() const
return the height of the drawing panels.
virtual void drawLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col1, const DrawColour &col2, bool rawCoords=false)
draw a line where the ends are different colours
virtual void setFontSize(double new_size)
virtual Point2D getAtomCoords(int at_num) const
virtual void getStringSize(const std::string &label, double &label_width, double &label_height) const
virtual void drawArrow(const Point2D &cds1, const Point2D &cds2, bool asPolygon=false, double frac=0.05, double angle=M_PI/6, const DrawColour &col=DrawColour(0.0, 0.0, 0.0), bool rawCoords=false)
Draw an arrow with either lines or a filled head (when asPolygon is true)
void drawReaction(const ChemicalReaction &rxn, bool highlightByReactant=false, const std::vector< DrawColour > *highlightColorsReactants=nullptr, const std::vector< int > *confIds=nullptr)
draw a ChemicalReaction
void setFlexiMode(bool mode)
bool hasActiveBndIdx() const
void drawMolecule(const ROMol &mol, const std::string &legend, const std::vector< int > *highlight_atoms, const std::vector< int > *highlight_bonds, const std::map< int, DrawColour > *highlight_atom_map=nullptr, const std::map< int, DrawColour > *highlight_bond_map=nullptr, const std::map< int, double > *highlight_radii=nullptr, int confId=-1)
draw a single molecule
int getActiveAtmIdx2() const
virtual void drawLine(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false)=0
MolDraw2D(int width, int height, int panelWidth, int panelHeight)
constructor for a particular size
void getLabelSize(const std::string &label, MolDraw2D_detail::OrientType orient, double &label_width, double &label_height) const
double getDrawLineWidth() const
std::unique_ptr< MolDraw2D_detail::DrawText > text_drawer_
virtual double lineWidth() const
returns the current line width
int height() const
return the height of the drawing area.
void getStringExtremes(const std::string &label, MolDraw2D_detail::OrientType orient, const Point2D &cds, double &x_min, double &y_min, double &x_max, double &y_max) const
virtual bool fillPolys() const
set whether or not polygons are being filled
virtual void drawWavyLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col1, const DrawColour &col2, unsigned int nSegments=16, double vertOffset=0.05, bool rawCoords=false)
draw a wavy line like that used to indicate unknown stereochemistry
virtual void drawPlus(const Point2D &cds, int plusWidth, const DrawColour &col, bool rawCoords=false)
virtual bool supportsAnnotations() const
virtual void setDash(const DashPattern &patt)
sets the current dash pattern
virtual void drawString(const std::string &str, const Point2D &cds, bool rawCoords=false)
drawString centres the string on cds.
MolDraw2D(MolDraw2D &&rhs)=delete
virtual DrawColour colour() const
returns the current draw color
virtual void drawArc(const Point2D ¢re, double radius, double ang1, double ang2, bool rawCoords=false)
virtual void setColour(const DrawColour &col)
sets the current draw color
void drawMolecules(const std::vector< ROMol * > &mols, const std::vector< std::string > *legends=nullptr, const std::vector< std::vector< int > > *highlight_atoms=nullptr, const std::vector< std::vector< int > > *highlight_bonds=nullptr, const std::vector< std::map< int, DrawColour > > *highlight_atom_maps=nullptr, const std::vector< std::map< int, DrawColour > > *highlight_bond_maps=nullptr, const std::vector< std::map< int, double > > *highlight_radii=nullptr, const std::vector< int > *confIds=nullptr)
draw multiple molecules in a grid
const std::vector< Point2D > & atomCoords() const
int getActiveAtmIdx1() const
std::pair< int, int > getMolSize(const ROMol &mol, const std::string &legend="", const std::vector< int > *highlight_atoms=nullptr, const std::vector< int > *highlight_bonds=nullptr, const std::map< int, DrawColour > *highlight_atom_map=nullptr, const std::map< int, DrawColour > *highlight_bond_map=nullptr, const std::map< int, double > *highlight_radii=nullptr, int confId=-1)
returns the size of the box for the molecule with current drawing settings
Point2D range() const
returns the width and height of the grid (in molecular coords)
MolDraw2D(const MolDraw2D &rhs)=delete
virtual Point2D getDrawCoords(const Point2D &mol_cds) const
virtual void drawTriangle(const Point2D &cds1, const Point2D &cds2, const Point2D &cds3, bool rawCoords=false)
draw a triangle
const MolDrawOptions & drawOptions() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void drawString(const std::string &str, const Point2D &cds, MolDraw2D_detail::TextAlignType align, bool rawCoords=false)
virtual Point2D getDrawCoords(int at_num) const
returns the drawing coordinates of a particular atom
virtual Point2D getAtomCoords(const std::pair< int, int > &screen_cds) const
std::string d_activeClass
virtual void drawAttachmentLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col, double len=1.0, unsigned int nSegments=16, bool rawCoords=false)
void setOffset(int x, int y)
sets the drawing offset (in drawing coords)
virtual void setLineWidth(double width)
sets the current line width
void setActiveClass(std::string actClass=std::string(""))
virtual Point2D getAtomCoords(const std::pair< double, double > &screen_cds) const
virtual void setFillPolys(bool val)
returns either or not polygons should be filled
virtual void drawRect(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false)
draw a rectangle given two opposite corners
virtual void drawPolygon(const std::vector< Point2D > &cds, bool rawCoords=false)=0
virtual void drawEllipse(const Point2D &cds1, const Point2D &cds2, bool rawCoords=false)
draw an ellipse
void drawMolecule(const ROMol &mol, const std::vector< int > *highlight_atoms=nullptr, const std::map< int, DrawColour > *highlight_map=nullptr, const std::map< int, double > *highlight_radii=nullptr, int confId=-1)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setActiveMolIdx(int newIdx)
int panelWidth() const
return the width of the drawing panels.
virtual void clearDrawing()
clears the contents of the drawing
Point2D minPt() const
returns the minimum point of the drawing (in molecular coords)
const std::vector< std::pair< std::string, MolDraw2D_detail::OrientType > > & atomSyms() const
returns the atomic symbols of the activeMolIdx_ molecule
void setActiveAtmIdx(int at_idx1=-1, int at_idx2=-1)
Point2D offset() const
returns the drawing offset (in drawing coords)
virtual const DashPattern & dash() const
returns the current dash pattern
bool hasActiveAtmIdx() const
MolDraw2D & operator=(const MolDraw2D &rhs)=delete
int width() const
return the width of the drawing area.
std::vector< std::pair< std::string, std::string > > d_metadata
int getActiveBndIdx() const
virtual double fontSize() const
font size in drawing coordinate units. That's probably pixels.
std::string getActiveClass() const
void drawMolecule(const ROMol &mol, const std::vector< int > *highlight_atoms, const std::vector< int > *highlight_bonds, const std::map< int, DrawColour > *highlight_atom_map=nullptr, const std::map< int, DrawColour > *highlight_bond_map=nullptr, const std::map< int, double > *highlight_radii=nullptr, int confId=-1)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setScale(double newScale)
explicitly sets the scaling factors for the drawing
virtual void drawArc(const Point2D ¢re, double xradius, double yradius, double ang1, double ang2, bool rawCoords=false)
MolDrawOptions & drawOptions()
returns our current drawing options
RWMol is a molecule class that is intended to be edited.
#define RDKIT_MOLDRAW2D_EXPORT
std::vector< double > DashPattern
bool rdvalue_is(const RDValue_cast_t)
void setMonochromeMode(MolDrawOptions &opts, const DrawColour &fgColour, const DrawColour &bgColour)
void assignDarkModePalette(ColourPalette &palette)
void setDarkMode(MolDrawOptions &opts)