RDKit: MolDraw2DSVG.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MolDraw2DSVG.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2015 Greg Landrum
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 // derived from Dave Cosgrove's MolDraw2D
11 //
12 // This is a concrete class derived from MolDraw2D that uses RDKit to draw a
13 // molecule into an SVG file
14
15 #ifndef MOLDRAW2DSVG_H
16 #define MOLDRAW2DSVG_H
17
18 #include <iostream>
19 #include <sstream>
20 #include "MolDraw2D.h"
21
22 // ****************************************************************************
23
24 namespace RDKit {
25
26 class MolDraw2DSVG : public MolDraw2D {
27 public:
28 // initialize to use a particular ostream
29 MolDraw2DSVG(int width, int height, std::ostream &os, int panelWidth = -1,
30 int panelHeight = -1)
31 : MolDraw2D(width, height, panelWidth, panelHeight), d_os(os) {
32 initDrawing();
33 };
34 // initialize to use the internal stringstream
35 MolDraw2DSVG(int width, int height, int panelWidth = -1, int panelHeight = -1)
36 : MolDraw2D(width, height, panelWidth, panelHeight), d_os(d_ss) {
37 initDrawing();
38 };
39
40 // set font size in molecule coordinate units. That's probably Angstrom for
41 // RDKit. It will turned into drawing units using scale_, which might be
42 // changed as a result, to make sure things still appear in the window.
43 void setFontSize(double new_size);
44 void setColour(const DrawColour &col);
45
46 // not sure if this goes here or if we should do a dtor since initDrawing() is
47 // called in the ctor,
48 // but we'll start here
49 void finishDrawing();
50
51 void drawLine(const Point2D &cds1, const Point2D &cds2);
52 void drawString(const std::string &str, const Point2D &cds);
53 void drawPolygon(const std::vector<Point2D> &cds);
54 void drawEllipse(const Point2D &cds1, const Point2D &cds2);
55 void clearDrawing();
56
57 void drawWavyLine(const Point2D &cds1, const Point2D &cds2,
58 const DrawColour &col1, const DrawColour &col2,
59 unsigned int nSegments = 16, double vertOffset = 0.05);
60
61 // using the current scale, work out the size of the label in molecule
62 // coordinates
63 void getStringSize(const std::string &label, double &label_width,
64 double &label_height) const;
65
66 // this only makes sense if the object was initialized without a stream
67 std::string getDrawingText() const { return d_ss.str(); };
68
69 void tagAtoms(const ROMol &mol);
70
71 private:
72 std::ostream &d_os;
73 std::stringstream d_ss;
74
75 void drawChar(char c, const Point2D &cds);
76 void initDrawing();
77 };
78 }
79 #endif // MOLDRAW2DSVG_H
RDKit::MolDraw2D::height
virtual int height() const
return the height of the drawing area.
Definition: MolDraw2D.h:284
RDKit::MolDraw2DSVG::setColour
void setColour(const DrawColour &col)
sets the current draw color
RDKit::MolDraw2DSVG::getStringSize
void getStringSize(const std::string &label, double &label_width, double &label_height) const
RDGeom::Point2D
Definition: point.h:254
RDKit::MolDraw2D::panelHeight
virtual int panelHeight() const
return the height of the drawing panels.
Definition: MolDraw2D.h:288
RDKit::MolDraw2DSVG::tagAtoms
void tagAtoms(const ROMol &mol)
MolDraw2D.h
RDKit::ROMol
ROMol is a molecule class that is intended to have a fixed topology.
Definition: ROMol.h:103
RDKit::MolDraw2DSVG::drawLine
void drawLine(const Point2D &cds1, const Point2D &cds2)
draws a line from cds1 to cds2 using the current drawing style
RDKit::MolDraw2DSVG::MolDraw2DSVG
MolDraw2DSVG(int width, int height, int panelWidth=-1, int panelHeight=-1)
Definition: MolDraw2DSVG.h:35
RDKit::MolDraw2DSVG::drawString
void drawString(const std::string &str, const Point2D &cds)
drawString centres the string on cds.
RDKit::MolDraw2DSVG::finishDrawing
void finishDrawing()
RDKit::MolDraw2DSVG::drawPolygon
void drawPolygon(const std::vector< Point2D > &cds)
draw a polygon
RDKit::MolDraw2DSVG::getDrawingText
std::string getDrawingText() const
Definition: MolDraw2DSVG.h:67
RDKit::MolDraw2DSVG::drawEllipse
void drawEllipse(const Point2D &cds1, const Point2D &cds2)
draw an ellipse
RDKit::MolDraw2DSVG::setFontSize
void setFontSize(double new_size)
RDKit::MolDraw2DSVG
Definition: MolDraw2DSVG.h:26
RDKit::MolDraw2DSVG::drawWavyLine
void drawWavyLine(const Point2D &cds1, const Point2D &cds2, const DrawColour &col1, const DrawColour &col2, unsigned int nSegments=16, double vertOffset=0.05)
draw a wavy line like that used to indicate unknown stereochemistry
RDKit::MolDraw2DSVG::clearDrawing
void clearDrawing()
clears the contes of the drawingd]
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::MolDraw2D::width
virtual int width() const
return the width of the drawing area.
Definition: MolDraw2D.h:282
RDKit::MolDraw2D::panelWidth
virtual int panelWidth() const
return the width of the drawing panels.
Definition: MolDraw2D.h:286
RDKit::MolDraw2D
MolDraw2D is the base class for doing 2D renderings of molecules.
Definition: MolDraw2D.h:132
RDKit::MolDraw2DSVG::MolDraw2DSVG
MolDraw2DSVG(int width, int height, std::ostream &os, int panelWidth=-1, int panelHeight=-1)
Definition: MolDraw2DSVG.h:29
RDKit::DrawColour
boost::tuple< float, float, float > DrawColour
Definition: MolDraw2D.h:38