scatter 0.1.0
CairoRenderer.hpp
1/*
2 * Copyright (C) Tobias Löw (tobi.loew@protonmail.ch)
3 *
4 * This file is part of Scatter
5 *
6 * Scatter is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * Scatter is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Scatter. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <cairomm/context.h>
23#include <cairomm/surface.h>
24#include <pangomm/fontdescription.h>
25
26#include <scatter/render/Renderer.hpp>
27#include <string>
28
29namespace scatter
30{
31 class Point;
32
37 class CairoRenderer : public Renderer
38 {
39 public:
48 CairoRenderer(const std::string &filename, const double &width, const double &height);
49
54 virtual ~CairoRenderer();
55
63 void restrictArea(const Point &p1, const Point &p2);
64
72 void area(const std::vector<Point> &points, const Colour &colour = Colour());
73
83 void circle(const Point &p, const double &radius, const Colour &colour = Colour(), bool fill = true);
84
94 void line(const Point &p1, const Point &p2, const Colour &colour = Colour(), const double &line_width = 0.1);
95
105 void rectangle(const Point &p1, const Point &p2, const Colour &colour = Colour(), bool fill = true);
106
118 void ellipse(const Point &p, const double &minor, const double &major, const double &rotation, const Colour &colour = Colour(),
119 bool fill = true);
120
129 void asterisk(const Point &p, const double &radius, const Colour &colour = Colour());
130
139 void cross(const Point &p, const double &radius, const Colour &colour = Colour());
140
149 void plus(const Point &p, const double &radius, const Colour &colour = Colour());
150
160 void triangle(const Point &p, const double &radius, const Colour &colour = Colour(), bool fill = true);
161
171 void diamond(const Point &p, const double &radius, const Colour &colour = Colour(), bool fill = true);
172
182 void square(const Point &p, const double &radius, const Colour &colour = Colour(), bool fill = true);
183
193 void star(const Point &p, const double &radius, const Colour &colour = Colour(), bool fill = true);
194
205 void arrow(const Point &p1, const Point &p2, const Point &p3, const Point &p4, const Colour &colour = Colour());
206
215 void text(const Point &p, const std::string &label, const TextOptions &options = TextOptions());
216
225 void text(const Point &p, const std::string &label, const Anchor &anchor);
226
234 double getCharWidth(const TextOptions &options);
235
236 protected:
244 Pango::FontDescription makeFont(const TextOptions &options);
245
255 void draw(const std::function<void()> &drawing_function, const Colour &colour, bool fill, const double &line_width = 0.1);
256
257 private:
259 Cairo::RefPtr<Cairo::Surface> surface_;
261 Cairo::RefPtr<Cairo::Context> context_;
262 };
263
264} // namespace scatter
[brief description]
Definition CairoRenderer.hpp:38
void text(const Point &p, const std::string &label, const Anchor &anchor)
[brief description]
virtual ~CairoRenderer()
[brief description]
void draw(const std::function< void()> &drawing_function, const Colour &colour, bool fill, const double &line_width=0.1)
[brief description]
void rectangle(const Point &p1, const Point &p2, const Colour &colour=Colour(), bool fill=true)
[brief description]
void asterisk(const Point &p, const double &radius, const Colour &colour=Colour())
[brief description]
double getCharWidth(const TextOptions &options)
[brief description]
void square(const Point &p, const double &radius, const Colour &colour=Colour(), bool fill=true)
[brief description]
void ellipse(const Point &p, const double &minor, const double &major, const double &rotation, const Colour &colour=Colour(), bool fill=true)
[brief description]
void star(const Point &p, const double &radius, const Colour &colour=Colour(), bool fill=true)
[brief description]
void plus(const Point &p, const double &radius, const Colour &colour=Colour())
[brief description]
void area(const std::vector< Point > &points, const Colour &colour=Colour())
[brief description]
CairoRenderer(const std::string &filename, const double &width, const double &height)
[brief description]
void line(const Point &p1, const Point &p2, const Colour &colour=Colour(), const double &line_width=0.1)
[brief description]
void cross(const Point &p, const double &radius, const Colour &colour=Colour())
[brief description]
void diamond(const Point &p, const double &radius, const Colour &colour=Colour(), bool fill=true)
[brief description]
void text(const Point &p, const std::string &label, const TextOptions &options=TextOptions())
[brief description]
Pango::FontDescription makeFont(const TextOptions &options)
[brief description]
void triangle(const Point &p, const double &radius, const Colour &colour=Colour(), bool fill=true)
[brief description]
void circle(const Point &p, const double &radius, const Colour &colour=Colour(), bool fill=true)
[brief description]
void arrow(const Point &p1, const Point &p2, const Point &p3, const Point &p4, const Colour &colour=Colour())
[brief description]
void restrictArea(const Point &p1, const Point &p2)
[brief description]
define a RGBA colour
Definition Colour.hpp:34
[brief description]
Definition Point.hpp:29
[brief description]
Definition Renderer.hpp:38
[brief description]
Definition TextOptions.hpp:32