| 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_QTGUI_QTTEXTRENDERSTRATEGY_H |
| 7 |
#define AVOGADRO_QTGUI_QTTEXTRENDERSTRATEGY_H |
| 8 |
|
| 9 |
#include "avogadroqtopenglexport.h" |
| 10 |
#include <avogadro/rendering/textrenderstrategy.h> |
| 11 |
|
| 12 |
#include <avogadro/core/avogadrocore.h> |
| 13 |
|
| 14 |
namespace Avogadro { |
| 15 |
namespace QtOpenGL { |
| 16 |
|
| 17 |
/** |
| 18 |
* @class QtTextRenderStrategy qttextrenderstrategy.h |
| 19 |
* <avogadro/qtopengl/qttextrenderstrategy.h> |
| 20 |
* @brief The QtTextRenderStrategy class uses the Qt toolkit to render text. |
| 21 |
*/ |
| 22 |
class AVOGADROQTOPENGL_EXPORT QtTextRenderStrategy |
| 23 |
: public Rendering::TextRenderStrategy |
| 24 |
{ |
| 25 |
public: |
| 26 |
QtTextRenderStrategy(); |
| 27 |
~QtTextRenderStrategy() override; |
| 28 |
|
| 29 |
TextRenderStrategy* newInstance() const override; |
| 30 |
|
| 31 |
void boundingBox(const std::string& string, |
| 32 |
const Rendering::TextProperties& tprop, |
| 33 |
int bbox[4]) const override; |
| 34 |
|
| 35 |
void render(const std::string& string, const Rendering::TextProperties& tprop, |
| 36 |
unsigned char* buffer, const Vector2i& dims) const override; |
| 37 |
|
| 38 |
/** |
| 39 |
* Keep the buffer as a QImage::Format_ARGB32_Premultiplied image. Useful |
| 40 |
* for testing. |
| 41 |
* @note The result buffer may or may not actually be ARGB ordered depending |
| 42 |
* on system endianness. See the QImage docs for more info. |
| 43 |
* @{ |
| 44 |
*/ |
| 45 |
bool preserveArgb() const { return m_preserveArgb; } |
| 46 |
void setPreserveArgb(bool b) { m_preserveArgb = b; } |
| 47 |
/** @} */ |
| 48 |
|
| 49 |
private: |
| 50 |
static void argbToRgba(unsigned char* buffer, size_t pixels); |
| 51 |
bool m_preserveArgb; |
| 52 |
}; |
| 53 |
|
| 54 |
} // namespace QtOpenGL |
| 55 |
} // namespace Avogadro |
| 56 |
|
| 57 |
#endif // AVOGADRO_QTOPENGL_QTTEXTRENDERSTRATEGY_H |