20 #include <wx/colour.h> 43 wxFont font = m_dc.GetFont();
45 font.SetPixelSize(wxSize(0, font_size_in_points));
51 double r = col.get<0>();
52 double g = col.get<1>();
53 double b = col.get<2>();
54 wxColour
colour(r * 255, g * 255, b * 255);
55 m_dc.SetTextForeground(colour);
56 m_dc.SetPen(wxPen(colour));
57 m_dc.SetBrush(wxBrush(colour));
63 m_dc.DrawLine(c1.
x, c1.
y, c2.
x, c2.
y);
67 m_dc.DrawText(wxString(c), cds.
x, cds.
y);
71 PRECONDITION(cds.size() >= 3,
"must have at least three points");
72 wxPoint lines[cds.size()];
73 for (
unsigned int i = 0; i < cds.size(); ++i) {
75 lines[i] = wxPoint(c1.
x, c1.
y);
78 m_dc.DrawPolygon(cds.size(), lines);
82 const wxBrush &brush = m_dc.GetBrush();
83 const wxPen &pen = m_dc.GetPen();
93 double &label_height)
const {
94 if (m_dc.CanGetTextExtent()) {
96 m_dc.GetTextExtent(wxString(label), &width, &height);
97 label_width = double(width) /
scale();
98 label_height = double(height) /
scale();
106 #endif // MOLDRAW2DWX_H void setColour(const DrawColour &col)
sets the current draw color
virtual void setColour(const DrawColour &col)
sets the current draw color
virtual double fontSize() const
returns the font size (in nolecule units)
virtual int height() const
return the height of the drawing area.
void drawPolygon(const std::vector< Point2D > &cds)
draw a polygon
void setFontSize(double new_size)
void drawChar(char c, const Point2D &cds)
void getStringSize(const std::string &label, double &label_width, double &label_height) const
virtual int panelWidth() const
return the width of the drawing panels.
virtual DrawColour colour() const
returns the current draw color
void drawLine(const Point2D &cds1, const Point2D &cds2)
draws a line from cds1 to cds2 using the current drawing style
MolDraw2Dwx(int width, int height, wxDC &dc, int panelWidth=-1, int panelHeight=-1)
MolDrawOptions & drawOptions()
returns our current drawing options
DrawColour backgroundColour
void clearDrawing()
clears the contes of the drawingd]
virtual int panelHeight() const
return the height of the drawing panels.
virtual void setFontSize(double new_size)
double scale() const
returns the drawing scale (conversion from molecular coords -> drawing
MolDraw2D is the base class for doing 2D renderings of molecules.
virtual int width() const
return the width of the drawing area.
#define PRECONDITION(expr, mess)
virtual Point2D getDrawCoords(const Point2D &mol_cds) const
boost::tuple< float, float, float > DrawColour