Open Babel  3.0
cairopainter.h
Go to the documentation of this file.
1 #ifndef OB_CAIROPAINTER_H
2 #define OB_CAIROPAINTER_H
3 
5 #include "cairo.h"
6 
7 namespace OpenBabel
8 {
9  class CairoPainter : public OBPainter
10  {
11  public:
12  CairoPainter();
13  ~CairoPainter();
15 
16  void NewCanvas(double width, double height);
17  bool IsGood() const;
18  void SetFontFamily(const std::string &fontFamily) {} // FIXME
19  void SetFontSize(int pointSize);
20  void SetFillColor(const OBColor &color);
21  void SetFillRadial(const OBColor &start, const OBColor &end);
22  void SetPenColor(const OBColor &color);
23  void SetPenWidth(double width);
24  double GetPenWidth();
25  void DrawLine(double x1, double y1, double x2, double y2, const std::vector<double> & dashes=std::vector<double>());
26  void DrawPolygon(const std::vector<std::pair<double,double> > &points);
27  void DrawCircle(double x, double y, double r);
28  void DrawBall(double x, double y, double r, double opacity);
29  void DrawText(double x, double y, const std::string &text);
30  OBFontMetrics GetFontMetrics(const std::string &text);
32 
34 
35  void WriteImage(const std::string &filename);
36  void WriteImage(std::ostream& ofs);
37  void SetWidth(int width) {m_width=width;}
38  void SetHeight(int height) {m_height=height;}
39  void SetTitle(std::string title) {m_title=title;}
40  void SetIndex(int index) {m_index=index;}
41  void SetTableSize(int nrows, int ncols) {m_nrows=nrows; m_ncols=ncols;}
42  void SetBackground(std::string color) {m_fillcolor=color;}
43  void SetBondColor(std::string color) {m_bondcolor=color;}
44  void SetTransparent(bool tr) {m_transparent=tr;}
45  void SetCropping(bool cr) {m_cropping=cr;}
47 
48  private:
49  cairo_surface_t *m_surface;
50  cairo_t *m_cairo;
51  int m_fontPointSize;
52  int m_width;
53  int m_height;
54  double m_pen_width;
55  std::string m_title;
56  int m_index; // Index of current molecule in a table
57  int m_ncols, m_nrows; // number of rows and columns
58  std::string m_fillcolor, m_bondcolor;
59  bool m_transparent, m_cropping;
60 
61  };
62 
63 }
64 
65 #endif
void SetBackground(std::string color)
Definition: cairopainter.h:42
void SetPenColor(const OBColor &color)
Definition: cairopainter.cpp:107
Abstract painter base class used by OBDepict.
Definition: painter.h:128
OBFontMetrics GetFontMetrics(const std::string &text)
Definition: cairopainter.cpp:154
void SetFontSize(int pointSize)
Definition: cairopainter.cpp:91
void SetTitle(std::string title)
Definition: cairopainter.h:39
void SetBondColor(std::string color)
Definition: cairopainter.h:43
Definition: cairopainter.h:9
bool IsGood() const
Definition: cairopainter.cpp:82
CairoPainter()
Definition: cairopainter.cpp:11
void SetFillRadial(const OBColor &start, const OBColor &end)
Definition: cairopainter.cpp:102
Color class used by OBDepict.
Definition: painter.h:37
Font metrics class used by OBDepict.
Definition: painter.h:116
void SetPenWidth(double width)
Definition: cairopainter.cpp:112
void SetFillColor(const OBColor &color)
Definition: cairopainter.cpp:97
void SetFontFamily(const std::string &fontFamily)
Definition: cairopainter.h:18
void DrawText(double x, double y, const std::string &text)
Definition: cairopainter.cpp:148
double GetPenWidth()
Definition: cairopainter.cpp:117
void DrawPolygon(const std::vector< std::pair< double, double > > &points)
Definition: cairopainter.cpp:132
void SetTransparent(bool tr)
Definition: cairopainter.h:44
void DrawLine(double x1, double y1, double x2, double y2, const std::vector< double > &dashes=std::vector< double >())
Definition: cairopainter.cpp:122
void SetWidth(int width)
Definition: cairopainter.h:37
void DrawCircle(double x, double y, double r)
Definition: cairopainter.cpp:142
Base class for graphical 2D depiction classes (e.g., "paint" to SVG)
~CairoPainter()
Definition: cairopainter.cpp:17
void DrawBall(double x, double y, double r, double opacity)
Definition: cairopainter.cpp:186
void NewCanvas(double width, double height)
Definition: cairopainter.cpp:25
void SetTableSize(int nrows, int ncols)
Definition: cairopainter.h:41
void SetIndex(int index)
Definition: cairopainter.h:40
void WriteImage(const std::string &filename)
Definition: cairopainter.cpp:170
void SetHeight(int height)
Definition: cairopainter.h:38
void SetCropping(bool cr)
Definition: cairopainter.h:45
Global namespace for all Open Babel code.
Definition: alias.h:22