30 MolDraw2Dwx(
int width,
int height, wxDC &dc,
int panelWidth = -1,
32 :
MolDraw2D(width, height, panelWidth, panelHeight), m_dc(dc) {
42 MolDraw2D::setFontSize(new_size);
43 double font_size_in_points = fontSize() * scale();
44 wxFont font = m_dc.GetFont();
46 font.SetPixelSize(wxSize(0, font_size_in_points));
51 MolDraw2D::setColour(col);
52 double r = col.get<0>();
53 double g = col.get<1>();
54 double b = col.get<2>();
55 wxColour colour(r * 255, g * 255, b * 255);
56 m_dc.SetTextForeground(colour);
57 m_dc.SetPen(wxPen(colour));
58 m_dc.SetBrush(wxBrush(colour));
62 Point2D c1 = getDrawCoords(cds1);
63 Point2D c2 = getDrawCoords(cds2);
64 m_dc.DrawLine(c1.
x, c1.
y, c2.
x, c2.
y);
68 m_dc.DrawText(wxString(c), cds.
x, cds.
y);
72 PRECONDITION(cds.size() >= 3,
"must have at least three points");
73 wxPoint lines[cds.size()];
74 for (
unsigned int i = 0; i < cds.size(); ++i) {
75 Point2D c1 = getDrawCoords(cds[i]);
76 lines[i] = wxPoint(c1.
x, c1.
y);
79 m_dc.DrawPolygon(cds.size(), lines);
83 const wxBrush &brush = m_dc.GetBrush();
84 const wxPen &pen = m_dc.GetPen();
85 setColour(drawOptions.backgroundColour);
86 m_dc.DrawRectangle(0, 0, width(), height());
94 double &label_height)
const {
95 if (m_dc.CanGetTextExtent()) {
96 wxCoord width, height;
97 m_dc.GetTextExtent(wxString(label), &width, &height);
98 label_width = double(width) / scale();
99 label_height = double(height) / scale();
#define PRECONDITION(expr, mess)
MolDraw2D is the base class for doing 2D renderings of molecules.
void getStringSize(const std::string &label, double &label_width, double &label_height) const
void setColour(const DrawColour &col)
sets the current draw color
void drawPolygon(const std::vector< Point2D > &cds)
void drawChar(char c, const Point2D &cds)
void clearDrawing()
clears the contents of the drawing
void drawLine(const Point2D &cds1, const Point2D &cds2)
void setFontSize(double new_size)
MolDraw2Dwx(int width, int height, wxDC &dc, int panelWidth=-1, int panelHeight=-1)
#define RDKIT_MOLDRAW2D_EXPORT