Debian Codegraph @

avogadro/rendering/textrenderstrategy.h

raw
1 /******************************************************************************
2 This source file is part of the Avogadro project.
3 This source code is released under the 3-Clause BSD License, (see "LICENSE").
4 ******************************************************************************/
5
6 #ifndef AVOGADRO_RENDERING_TEXTRENDERSTRATEGY_H
7 #define AVOGADRO_RENDERING_TEXTRENDERSTRATEGY_H
8
9 #include "avogadrorenderingexport.h"
10
11 #include <avogadro/core/vector.h>
12
13 #include <string>
14
15 namespace Avogadro {
16 namespace Rendering {
17 class TextProperties;
18
19 /**
20 * @class TextRenderStrategy textrenderstrategy.h
21 * <avogadro/rendering/textrenderstrategy.h>
22 * @brief The TextRenderStrategy class defines an interface for generating
23 * text images.
24 */
25 class AVOGADRORENDERING_EXPORT TextRenderStrategy
26 {
27 public:
28 TextRenderStrategy();
29 virtual ~TextRenderStrategy();
30
31 /**
32 * Copy the current TextRenderStrategy implementation into an new object.
33 */
34 virtual TextRenderStrategy* newInstance() const = 0;
35
36 /**
37 * @brief Calculate a bounding box.
38 * @param string The text.
39 * @param tprop The properties.
40 * @param bbox The result in pixels (left, right, top, bottom).
41 */
42 virtual void boundingBox(const std::string& string,
43 const TextProperties& tprop, int bbox[4]) const = 0;
44
45 /**
46 * @brief render Render the string.
47 * @param string The text.
48 * @param tprop The properties.
49 * @param buffer The target. Must be dims[0]*dims[1]*4
50 * bytes. The buffer will be filled with RGBA image data, with the top
51 * scan row at the beginning.
52 * @param dims Dimensions in pixels of the target buffer.
53 */
54 virtual void render(const std::string& string, const TextProperties& tprop,
55 unsigned char* buffer, const Vector2i& dims) const = 0;
56 };
57
58 } // namespace Rendering
59 } // namespace Avogadro
60
61 #endif // AVOGADRO_RENDERING_TEXTRENDERSTRATEGY_H