Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / chart2 / source / view / inc / 3DChartObjects.hxx
blob43213774742493d0bb9b4536a2e9bccff802afe7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_CHART2_SOURCE_VIEW_INC_3DCHARTOBJECTS_HXX
11 #define INCLUDED_CHART2_SOURCE_VIEW_INC_3DCHARTOBJECTS_HXX
13 #include <glm/glm.hpp>
14 #include <tools/color.hxx>
15 #include <vcl/bitmapex.hxx>
17 #include <vcl/opengl/OpenGLContext.hxx>
18 #include "GL3DRenderer.hxx"
20 #include <boost/shared_array.hpp>
22 #include <map>
24 namespace chart {
26 namespace opengl3D {
28 struct TextCacheItem
30 TextCacheItem(sal_uInt8 *pPixels, ::Size aSize)
31 : maSize(aSize), maPixels(pPixels)
34 ::Size maSize;
35 boost::shared_array<sal_uInt8> maPixels;
38 class TextCache
40 public:
41 const TextCacheItem &getText(OUString const & rText, bool bIs3dText = false);
42 private:
43 typedef std::map<OUString const, TextCacheItem> TextCacheType;
45 TextCacheType m_TextCache;
48 class Renderable3DObject
50 public:
51 Renderable3DObject(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
53 virtual ~Renderable3DObject() {};
55 virtual void render();
57 protected:
58 OpenGL3DRenderer* mpRenderer;
59 sal_uInt32 mnUniqueId;
62 class Bar : public Renderable3DObject
64 public:
65 Bar(OpenGL3DRenderer* pRenderer, const glm::mat4& rPosition, Color nColor, sal_uInt32 nId);
67 virtual void render() override;
68 private:
69 glm::mat4 maPos;
70 Color maColor; // RGBA fill color
73 class Line : public Renderable3DObject
75 public:
76 Line(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
78 virtual void render() override;
80 void setPosition(const glm::vec3& rBegin, const glm::vec3& rEnd);
81 void setLineColor(const Color& rColor);
83 private:
84 glm::vec3 maPosBegin;
85 glm::vec3 maPosEnd;
86 Color maLineColor; // RGBA line color
89 class Text : public Renderable3DObject
91 public:
92 Text(OpenGL3DRenderer* pRenderer, TextCache& rTextCache, const OUString& rStr, sal_uInt32 nId);
93 virtual void render() override;
95 void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight);
97 private:
98 TextCacheItem maText;
99 glm::vec3 maTopLeft;
100 glm::vec3 maTopRight;
101 glm::vec3 maBottomRight;
104 class ScreenText : public Renderable3DObject
106 public:
107 ScreenText(OpenGL3DRenderer* pRenderer, TextCache& rTextCache,
108 const OUString& rStr, const glm::vec4& rColor, sal_uInt32 nId, bool bIs3dText = false);
110 virtual void render() override;
111 void setPosition(const glm::vec2& rTopLeft, const glm::vec2& rBottomRight,
112 const glm::vec3& r3DPos);
114 private:
115 TextCacheItem maText;
116 glm::vec2 maTopLeft;
117 glm::vec2 maBottomRight;
118 glm::vec3 ma3DPos;
119 glm::vec4 maColor;
122 class Rectangle : public Renderable3DObject
124 public:
125 Rectangle(OpenGL3DRenderer* pRenderer, sal_uInt32 nId);
126 virtual void render() override;
128 void setPosition(const glm::vec3& rTopLeft, const glm::vec3& rTopRight, const glm::vec3& rBottomRight);
129 void setFillColor(const Color& rColor);
130 void setLineColor(const Color& rColor);
132 private:
133 glm::vec3 maTopLeft;
134 glm::vec3 maTopRight;
135 glm::vec3 maBottomRight;
136 Color maColor; // RGBA fill color
137 Color maLineColor; // RGBA line color
140 class Camera : public Renderable3DObject
142 public:
143 Camera(OpenGL3DRenderer* pRenderer);
144 virtual void render() override;
146 void setPosition(const glm::vec3& rPos);
147 void setDirection(const glm::vec3& rPos);
149 private:
150 glm::vec3 maPos;
151 glm::vec3 maUp;
152 glm::vec3 maDirection;
159 #endif // INCLUDED_CHART2_SOURCE_VIEW_INC_3DCHARTOBJECTS_HXX
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */