Bump version to 6.0-36
[LibreOffice.git] / slideshow / source / engine / opengl / Operation.hxx
blob0ee818f2457495a34ce26e72358a4bff3ae04f28
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2015 by Collabora, Ltd.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
28 #ifndef INCLUDED_OGLTRANS_OPERATIONS_HXX_
29 #define INCLUDED_OGLTRANS_OPERATIONS_HXX_
31 #include <config_lgpl.h>
32 #include <glm/gtc/type_ptr.hpp>
34 #include <memory>
36 /** This class is to be derived to make any operation (transform) you may need in order to construct your transitions
38 class Operation
40 public:
41 virtual ~Operation(){}
42 Operation(const Operation&) = delete;
43 Operation& operator=(const Operation&) = delete;
45 protected:
46 /** Should this operation be interpolated . If TRUE, the transform will smoothly move from making no difference from t = 0.0 to mnT0 to being completely transformed from t = mnT1 to 1. If FALSE, the transform will be ineffectual from t = 0 to mnT0, and completely transformed from t = mnT0 to 1.
48 bool mbInterpolate;
50 /** time to begin the transformation
52 double mnT0;
54 /** time to finish the transformation
56 double mnT1;
57 public:
58 /** this is the function that is called to give the Operation to OpenGL.
60 @param t
61 time from t = 0 to t = 1
63 @param SlideWidthScale
64 width of slide divided by width of window
66 @param SlideHeightScale
67 height of slide divided by height of window
70 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const = 0;
72 protected:
73 Operation(bool bInterpolate, double nT0, double nT1):
74 mbInterpolate(bInterpolate), mnT0(nT0), mnT1(nT1){}
77 /** this class is a generic CounterClockWise(CCW) rotation with an axis angle
79 class SRotate: public Operation
81 public:
82 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
84 /** Constructor
86 @param Axis
87 axis to rotate about
89 @param Origin
90 position that rotation axis runs through
92 @param Angle
93 angle in degrees of CCW rotation
95 @param bInter
96 see Operation
98 @param T0
99 transformation starting time
101 @param T1
102 transformation ending time
105 SRotate(const glm::vec3& Axis, const glm::vec3& Origin, double Angle,
106 bool bInter, double T0, double T1);
107 private:
108 /** axis to rotate CCW about
110 glm::vec3 axis;
112 /** position that rotation axis runs through
114 glm::vec3 origin;
116 /** angle in degrees of CCW rotation
118 double angle;
121 std::shared_ptr<SRotate>
122 makeSRotate(const glm::vec3& Axis, const glm::vec3& Origin, double Angle,
123 bool bInter, double T0, double T1);
125 /** scaling transformation
127 class SScale: public Operation
129 public:
130 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
132 /** Constructor
134 @param Scale
135 amount to scale by
137 @param Origin
138 position that rotation axis runs through
140 @param bInter
141 see Operation
143 @param T0
144 transformation starting time
146 @param T1
147 transformation ending time
150 SScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
151 private:
152 glm::vec3 scale;
153 glm::vec3 origin;
156 std::shared_ptr<SScale>
157 makeSScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
159 /** translation transformation
161 class STranslate: public Operation
163 public:
164 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
166 /** Constructor
168 @param Vector
169 vector to translate
171 @param bInter
172 see Operation
174 @param T0
175 transformation starting time
177 @param T1
178 transformation ending time
181 STranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
182 private:
183 /** vector to translate by
185 glm::vec3 vector;
188 std::shared_ptr<STranslate>
189 makeSTranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
191 /** translation transformation
193 class SEllipseTranslate: public Operation
195 public:
196 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
198 /** Constructor
200 @param Vector
201 vector to translate
203 @param bInter
204 see Operation
206 @param T0
207 transformation starting time
209 @param T1
210 transformation ending time
213 SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
214 private:
215 /** width and length of the ellipse
217 double width, height;
219 /** start and end position on the ellipse <0,1>
221 double startPosition;
222 double endPosition;
225 std::shared_ptr<SEllipseTranslate>
226 makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
228 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the width of the window.
230 class RotateAndScaleDepthByWidth: public Operation
232 public:
233 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
235 RotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
236 private:
237 glm::vec3 axis;
238 glm::vec3 origin;
239 double angle;
240 bool scale;
243 std::shared_ptr<RotateAndScaleDepthByWidth>
244 makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
246 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the height of the window.
248 class RotateAndScaleDepthByHeight: public Operation
250 public:
251 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
253 RotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
254 private:
255 glm::vec3 axis;
256 glm::vec3 origin;
257 double angle;
258 bool scale;
261 std::shared_ptr<RotateAndScaleDepthByHeight>
262 makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
264 #endif // INCLUDED_SLIDESHOW_OPERATIONS_HXX_
266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */