23 #ifndef RDKITMOLDRAW2D_H 24 #define RDKITMOLDRAW2D_H 38 double r = 0.0,
g = 0.0,
b = 0.0,
a = 1.0;
41 : r(r), g(g), b(b),
a(
a){};
43 return r == other.
r &&
g == other.
g &&
b == other.
b &&
a == other.
a;
46 bool ignoreAlpha =
true)
const {
47 return fabs(r - other.
r) <= tol && fabs(
g - other.
g) <= tol &&
48 fabs(
b - other.
b) <= tol &&
49 (ignoreAlpha || fabs(
a - other.
a) <= tol);
73 palette[1] = palette[6] =
DrawColour(0.0, 0.0, 0.0);
131 : atomLabelDeuteriumTritium(false),
132 dummiesAreAttachments(false),
134 highlightColour(1, .5, .5),
135 continuousHighlight(true),
136 fillHighlights(true),
137 flagCloseContactsDist(3),
138 includeAtomTags(false),
139 clearBackground(true),
140 backgroundColour(1, 1, 1),
142 legendColour(0, 0, 0),
143 multipleBondOffset(0.15),
145 additionalAtomLabelPadding(0.0),
146 symbolColour(0, 0, 0),
148 prepareMolsBeforeDrawing(true) {
149 highlightColourPalette.push_back(
151 highlightColourPalette.push_back(
DrawColour(1., .8, .6));
152 highlightColourPalette.push_back(
DrawColour(1., .71, .76));
153 highlightColourPalette.push_back(
DrawColour(.8, 1., .8));
154 highlightColourPalette.push_back(
DrawColour(.87, .63, .87));
155 highlightColourPalette.push_back(
DrawColour(.76, .94, .96));
156 highlightColourPalette.push_back(
DrawColour(.67, .67, 1.));
157 highlightColourPalette.push_back(
DrawColour(.64, .76, .34));
158 highlightColourPalette.push_back(
DrawColour(.56, .93, .56));
159 highlightColourPalette.push_back(
DrawColour(.20, .63, .79));
185 MolDraw2D(
int width,
int height,
int panelWidth,
int panelHeight)
186 : needs_scale_(true),
189 panel_width_(panelWidth > 0 ? panelWidth : width),
190 panel_height_(panelHeight > 0 ? panelHeight : height),
222 virtual void drawMolecule(
223 const ROMol &mol,
const std::string &legend,
224 const std::vector<int> *highlight_atoms,
225 const std::vector<int> *highlight_bonds,
226 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
227 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
228 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
231 virtual void drawMolecule(
232 const ROMol &mol,
const std::vector<int> *highlight_atoms =
nullptr,
233 const std::map<int, DrawColour> *highlight_map =
nullptr,
234 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
237 virtual void drawMolecule(
238 const ROMol &mol,
const std::string &legend,
239 const std::vector<int> *highlight_atoms =
nullptr,
240 const std::map<int, DrawColour> *highlight_map =
nullptr,
241 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
244 virtual void drawMolecule(
245 const ROMol &mol,
const std::vector<int> *highlight_atoms,
246 const std::vector<int> *highlight_bonds,
247 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
248 const std::map<int, DrawColour> *highlight_bond_map =
nullptr,
249 const std::map<int, double> *highlight_radii =
nullptr,
int confId = -1);
277 virtual void drawMolecules(
278 const std::vector<ROMol *> &mols,
279 const std::vector<std::string> *legends =
nullptr,
280 const std::vector<std::vector<int>> *highlight_atoms =
nullptr,
281 const std::vector<std::vector<int>> *highlight_bonds =
nullptr,
282 const std::vector<std::map<int, DrawColour>> *highlight_atom_maps =
284 const std::vector<std::map<int, DrawColour>> *highlight_bond_maps =
286 const std::vector<std::map<int, double>> *highlight_radii =
nullptr,
287 const std::vector<int> *confIds =
nullptr);
301 virtual void drawReaction(
303 const std::vector<DrawColour> *highlightColorsReactants =
nullptr,
304 const std::vector<int> *confIds =
nullptr);
320 virtual Point2D getDrawCoords(
int at_num)
const;
321 virtual Point2D getAtomCoords(
const std::pair<int, int> &screen_cds)
const;
325 const std::pair<double, double> &screen_cds)
const;
327 virtual Point2D getAtomCoords(
int at_num)
const;
331 virtual int width()
const {
return width_; }
333 virtual int height()
const {
return height_; }
341 double scale()
const {
return scale_; }
344 void calculateScale(
int width,
int height,
345 const std::vector<int> *highlight_atoms =
nullptr,
346 const std::map<int, double> *highlight_radii =
nullptr);
350 void setScale(
int width,
int height,
const Point2D &minv,
366 virtual double fontSize()
const {
return font_size_; }
369 virtual void setFontSize(
double new_size);
376 virtual void setDash(
const DashPattern &patt) { curr_dash_ = patt; }
378 virtual const DashPattern &
dash()
const {
return curr_dash_; }
389 bool setStringDrawMode(
const std::string &instring, TextDrawType &draw_mode,
392 virtual void clearDrawing() = 0;
394 virtual void drawLine(
const Point2D &cds1,
const Point2D &cds2) = 0;
403 virtual void getStringSize(
const std::string &label,
double &label_width,
404 double &label_height)
const = 0;
406 virtual void drawString(
const std::string &str,
const Point2D &cds);
409 virtual void drawPolygon(
const std::vector<Point2D> &cds) = 0;
411 virtual void drawTriangle(
const Point2D &cds1,
const Point2D &cds2,
414 virtual void drawEllipse(
const Point2D &cds1,
const Point2D &cds2);
419 virtual void drawAttachmentLine(
const Point2D &cds1,
const Point2D &cds2,
421 unsigned int nSegments = 16);
423 virtual void drawWavyLine(
const Point2D &cds1,
const Point2D &cds2,
425 unsigned int nSegments = 16,
426 double vertOffset = 0.05);
444 return at_cds_[activeMolIdx_];
447 const std::vector<std::pair<std::string, OrientType>> &
atomSyms()
const {
449 return atom_syms_[activeMolIdx_];
453 bool asPolygon =
false,
double frac = 0.05,
454 double angle =
M_PI / 6);
458 int width_, height_, panel_width_, panel_height_;
460 double x_min_, y_min_, x_range_, y_range_;
461 double x_trans_, y_trans_;
462 int x_offset_, y_offset_;
471 DashPattern curr_dash_;
474 std::vector<std::vector<Point2D>> at_cds_;
475 std::vector<std::vector<int>> atomic_nums_;
476 std::vector<std::vector<std::pair<std::string, OrientType>>> atom_syms_;
480 virtual void drawChar(
char c,
const Point2D &cds) = 0;
485 int atom_idx,
const std::vector<int> *highlight_atoms =
nullptr,
486 const std::map<int, DrawColour> *highlight_map =
nullptr);
487 DrawColour getColourByAtomicNum(
int atomic_num);
489 void extractAtomCoords(
const ROMol &mol,
int confId,
bool updateBBox);
490 void extractAtomSymbols(
const ROMol &mol);
497 void drawAtomLabel(
int atom_num,
498 const std::vector<int> *highlight_atoms =
nullptr,
499 const std::map<int, DrawColour> *highlight_map =
nullptr);
518 void adjustBondEndForLabel(
int atnum,
const Point2D &nbr_cds,
522 std::pair<std::string, OrientType> getAtomSymbolAndOrientation(
526 virtual void doContinuousHighlighting(
527 const ROMol &mol,
const std::vector<int> *highlight_atoms,
528 const std::vector<int> *highlight_bonds,
529 const std::map<int, DrawColour> *highlight_atom_map,
530 const std::map<int, DrawColour> *highlight_bond_map,
531 const std::map<int, double> *highlight_radii);
533 virtual void highlightCloseContacts();
534 virtual void drawBond(
535 const ROMol &mol,
const Bond *bond,
int at1_idx,
int at2_idx,
536 const std::vector<int> *highlight_atoms =
nullptr,
537 const std::map<int, DrawColour> *highlight_atom_map =
nullptr,
538 const std::vector<int> *highlight_bonds =
nullptr,
539 const std::map<int, DrawColour> *highlight_bond_map =
nullptr);
546 #endif // RDKITMOLDRAW2D_H virtual void setColour(const DrawColour &col)
sets the current draw color
virtual int lineWidth() const
returns the current line width
virtual void setLineWidth(int width)
sets the current line width
virtual double fontSize() const
returns the font size (in nolecule units)
DrawColour operator*(double v) const
virtual int height() const
return the height of the drawing area.
DrawColour(double r, double g, double b, double a=1.0)
std::vector< unsigned int > DashPattern
virtual int panelWidth() const
return the width of the drawing panels.
Point2D offset() const
returns the drawing offset (in drawing coords)
virtual void setDash(const DashPattern &patt)
sets the current dash pattern
const std::vector< Point2D > & atomCoords() const
virtual void setFillPolys(bool val)
returns ehther or not polygons should be filled
bool operator==(const DrawColour &other) const
virtual DrawColour colour() const
returns the current draw color
DrawColour operator-(const DrawColour &other) const
void assignBWPalette(ColourPalette &palette)
virtual bool fillPolys() const
set whether or not polygons are being filled
This is a class for storing and applying general chemical reactions.
pulls in the core RDKit functionality
Point2D range() const
returns the width and height of the grid (in molecular coords)
void setOffset(int x, int y)
sets the drawing offset (in drawing coords)
MolDrawOptions & drawOptions()
returns our current drawing options
DrawColour backgroundColour
const MolDrawOptions & drawOptions() const
virtual int panelHeight() const
return the height of the drawing panels.
DrawColour operator/(double v) const
bool feq(const DrawColour &other, double tol=0.001, bool ignoreAlpha=true) const
double additionalAtomLabelPadding
void assignDefaultPalette(ColourPalette &palette)
class for representing a bond
#define RDUNUSED_PARAM(x)
bool dummiesAreAttachments
double scale() const
returns the drawing scale (conversion from molecular coords -> drawing
virtual const DashPattern & dash() const
returns the current dash pattern
MolDraw2D is the base class for doing 2D renderings of molecules.
double multipleBondOffset
ColourPalette atomColourPalette
virtual int width() const
return the width of the drawing area.
#define PRECONDITION(expr, mess)
MolDraw2D(int width, int height, int panelWidth, int panelHeight)
constructor for a particular size
bool prepareMolsBeforeDrawing
Point2D minPt() const
returns the minimum point of the drawing (in molecular coords)
std::map< int, std::string > atomLabels
std::map< int, DrawColour > ColourPalette
std::vector< std::vector< int > > atomRegions
DrawColour highlightColour
#define RDKIT_MOLDRAW2D_EXPORT
std::vector< DrawColour > highlightColourPalette
int flagCloseContactsDist
The class for representing atoms.
const std::vector< std::pair< std::string, OrientType > > & atomSyms() const
returns the atomic symbols of the current molecule
bool atomLabelDeuteriumTritium
DrawColour operator+(const DrawColour &other) const
virtual void tagAtoms(const ROMol &mol)