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);
140 const ROMol &mol,
const std::string &legend,
141 const std::map<
int, std::vector<DrawColour>> &highlight_atom_map,
142 const std::map<
int, std::vector<DrawColour>> &highlight_bond_map,
143 const std::map<int, double> &highlight_radii,
144 const std::map<int, int> &highlight_linewidth_multipliers,
174 const std::vector<ROMol *> &mols,
175 const std::vector<std::string> *legends =
nullptr,
176 const std::vector<std::vector<int>> *highlight_atoms =
nullptr,
177 const std::vector<std::vector<int>> *highlight_bonds =
nullptr,
178 const std::vector<std::map<int, DrawColour>> *highlight_atom_maps =
180 const std::vector<std::map<int, DrawColour>> *highlight_bond_maps =
182 const std::vector<std::map<int, double>> *highlight_radii =
nullptr,
183 const std::vector<int> *confIds =
nullptr);
199 const std::vector<DrawColour> *highlightColorsReactants =
nullptr,
200 const std::vector<int> *confIds =
nullptr);
204 const ROMol &mol,
const std::string &legend =
"",
205 const std::vector<int> *highlight_atoms =
nullptr,
206 const std::vector<int> *highlight_bonds =
nullptr,
207 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
208 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
209 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
224 bool rawCoords =
false) = 0;
232 bool rawCoords =
false) = 0;
244 bool rawCoords =
false);
247 const Point2D &cds3,
bool rawCoords =
false);
250 bool rawCoords =
false);
256 double ang2,
bool rawCoords =
false);
259 double ang1,
double ang2,
bool rawCoords =
false);
262 bool rawCoords =
false);
267 unsigned int nSegments = 16,
268 bool rawCoords =
false);
272 unsigned int nSegments = 16,
273 double vertOffset = 0.05,
bool rawCoords =
false);
278 bool asPolygon =
false,
double frac = 0.05,
279 double angle =
M_PI / 6,
281 bool rawCoords =
false);
284 const DrawColour &col,
bool rawCoords =
false);
288 bool rawCoords =
false);
293 bool rawCoords =
false);
319 const std::pair<double, double> &screen_cds)
const;
328 const std::vector<std::pair<std::string, MolDraw2D_detail::OrientType>> &
332 int width()
const {
return width_; }
351 int drawHeight()
const {
return panel_height_ - legend_height_; }
361 const ROMol *mol =
nullptr);
390 drawOptions().bondLineWidth = width;
393 virtual double lineWidth()
const {
return drawOptions().bondLineWidth; }
403 double &label_height)
const;
408 double &label_height)
const;
412 const Point2D &cds,
double &x_min,
double &y_min,
413 double &x_max,
double &y_max)
const;
438 activeBndIdx_ = (bnd_idx < 0 ? -1 : bnd_idx);
441 d_activeClass = actClass;
448 bool needs_init_ =
true;
450 unsigned int d_numMetadataEntries = 0;
455 virtual void initDrawing() = 0;
456 virtual void initTextDrawer(
bool noFreetype) = 0;
464 void getReactionDrawMols(
466 const std::vector<DrawColour> *highlightColorsReactants,
467 const std::vector<int> *confIds,
468 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reagents,
469 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &products,
470 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &agents,
474 void makeReactionComponents(
475 std::vector<RDKit::ROMOL_SPTR>
const &bits,
476 const std::vector<int> *confIds,
int heightToUse,
477 std::map<int, DrawColour> &atomColours,
478 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &dms,
479 double &minScale,
double &minFontScale);
482 void makeReactionDrawMol(
483 RWMol &mol,
int confId,
int molHeight,
484 const std::vector<int> &highlightAtoms,
485 const std::vector<int> &highlightBonds,
486 const std::map<int, DrawColour> &highlightAtomMap,
487 const std::map<int, DrawColour> &highlightBondMap,
488 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &mols);
492 void calcReactionOffsets(
493 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reagents,
494 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &products,
495 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &agents,
496 int &plusWidth, std::vector<Point2D> &offsets,
Point2D &arrowBeg,
499 int drawReactionPart(
500 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> &reactBit,
501 int plusWidth,
int initOffset,
const std::vector<Point2D> &offsets);
504 void findReactionHighlights(
506 const std::vector<DrawColour> *highlightColorsReactants,
507 std::map<int, DrawColour> &atomColours)
const;
509 int width_, height_, panel_width_, panel_height_, legend_height_;
512 bool forceScale_ =
false;
513 bool flexiMode_ =
false;
514 double scale_, fontScale_;
515 int x_offset_, y_offset_;
523 std::vector<std::shared_ptr<MolDraw2D_detail::DrawMol>> drawMols_;
529 std::unique_ptr<MolDraw2D_detail::DrawMol> globalDrawTrans_;
538 void setupTextDrawer();
540 virtual void updateMetadata(
const ROMol &mol,
int confId) {
560 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)
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)