Loading...
Searching...
No Matches
asciipainter.h
Go to the documentation of this file.
/**********************************************************************
asciipainter.h - Render molecule as ASCII
Copyright (C) 2012 by Noel O'Boyle
This file is part of the Open Babel project.
For more information, see <http://openbabel.org/>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
#ifndef OB_ASCIIPAINTER_H
#define OB_ASCIIPAINTER_H
#include <openbabel/depict/painter.h>
namespace OpenBabel
{
class ASCIIPainter : public OBPainter
{
public:
ASCIIPainter(int width, int height, double aspect);
~ASCIIPainter();
void NewCanvas(double width, double height);
bool IsGood() const;
void SetFontFamily(const std::string &fontFamily) {}
void SetFontSize(int pointSize);
void SetFillColor(const OBColor &color);
void SetFillRadial(const OBColor &start, const OBColor &end);
void SetPenColor(const OBColor &color);
void SetPenWidth(double width);
double GetPenWidth();
void DrawLine(double x1, double y1, double x2, double y2, const std::vector<double> & dashes=std::vector<double>());
void DrawPolygon(const std::vector<std::pair<double,double> > &points);
void DrawCircle(double x, double y, double r);
void DrawBall(double x, double y, double r, double opacity = 1.0);
void DrawText(double x, double y, const std::string &text);
OBFontMetrics GetFontMetrics(const std::string &text);
void Write(std::ostream &ofs);
int round(double r);
std::string Bresenham(int x, int y, int x2, int y2, std::vector<std::pair<int, int> > &coords);
private:
std::vector<std::vector<char> > m_buf;
int m_width, m_height; // Width and height of output canvas in characters
double m_aspect; // Ratio of height:width for a single character
double m_scale; // Conversion from Depiction coords to m_buf coords
};
}
#endif
OpenBabel::ASCIIPainter::IsGood
bool IsGood() const
Definition asciipainter.cpp:49
OpenBabel::ASCIIPainter::GetPenWidth
double GetPenWidth()
Definition asciipainter.cpp:75
OpenBabel::ASCIIPainter::GetFontMetrics
OBFontMetrics GetFontMetrics(const std::string &text)
Definition asciipainter.cpp:124
OpenBabel::ASCIIPainter::Bresenham
std::string Bresenham(int x, int y, int x2, int y2, std::vector< std::pair< int, int > > &coords)
Definition asciipainter.cpp:191
OpenBabel::ASCIIPainter::SetFillRadial
void SetFillRadial(const OBColor &start, const OBColor &end)
Definition asciipainter.cpp:62
OpenBabel::ASCIIPainter::SetPenWidth
void SetPenWidth(double width)
Definition asciipainter.cpp:71
OpenBabel::ASCIIPainter::NewCanvas
void NewCanvas(double width, double height)
Definition asciipainter.cpp:42
OpenBabel::ASCIIPainter::ASCIIPainter
ASCIIPainter(int width, int height, double aspect)
Definition asciipainter.cpp:28
OpenBabel::ASCIIPainter::SetFontSize
void SetFontSize(int pointSize)
Definition asciipainter.cpp:54
OpenBabel::ASCIIPainter::DrawText
void DrawText(double x, double y, const std::string &text)
Definition asciipainter.cpp:114
OpenBabel::ASCIIPainter::SetFontFamily
void SetFontFamily(const std::string &fontFamily)
Definition asciipainter.h:34
OpenBabel::ASCIIPainter::SetFillColor
void SetFillColor(const OBColor &color)
Definition asciipainter.cpp:58
OpenBabel::ASCIIPainter::SetPenColor
void SetPenColor(const OBColor &color)
Definition asciipainter.cpp:67
OpenBabel::ASCIIPainter::DrawLine
void DrawLine(double x1, double y1, double x2, double y2, const std::vector< double > &dashes=std::vector< double >())
Definition asciipainter.cpp:80
OpenBabel::ASCIIPainter::~ASCIIPainter
~ASCIIPainter()
Definition asciipainter.cpp:38
OpenBabel::ASCIIPainter::DrawBall
void DrawBall(double x, double y, double r, double opacity=1.0)
Definition asciipainter.cpp:110
OpenBabel::ASCIIPainter::round
int round(double r)
Definition asciipainter.cpp:148
OpenBabel::ASCIIPainter::DrawPolygon
void DrawPolygon(const std::vector< std::pair< double, double > > &points)
Definition asciipainter.cpp:95
OpenBabel::ASCIIPainter::DrawCircle
void DrawCircle(double x, double y, double r)
Definition asciipainter.cpp:106
OpenBabel::ASCIIPainter::Write
void Write(std::ostream &ofs)
Definition asciipainter.cpp:136
OpenBabel::OBPainter
Abstract painter base class used by OBDepict.
Definition painter.h:129
OpenBabel
Global namespace for all Open Babel code.
Definition alias.h:23
painter.h
Base class for graphical 2D depiction classes (e.g., "paint" to SVG).
OpenBabel::OBColor
Color class used by OBDepict.
Definition painter.h:38
OpenBabel::OBFontMetrics
Font metrics class used by OBDepict.
Definition painter.h:117