build fix
[LibreOffice.git] / slideshow / source / engine / opengl / Operation.hxx
blob95aaa06df6fe4318e5adef4028a189a7410684b9
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 virtual ~SRotate() override {}
108 private:
109 /** axis to rotate CCW about
111 glm::vec3 axis;
113 /** position that rotation axis runs through
115 glm::vec3 origin;
117 /** angle in degrees of CCW rotation
119 double angle;
122 std::shared_ptr<SRotate>
123 makeSRotate(const glm::vec3& Axis, const glm::vec3& Origin, double Angle,
124 bool bInter, double T0, double T1);
126 /** scaling transformation
128 class SScale: public Operation
130 public:
131 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
133 /** Constructor
135 @param Scale
136 amount to scale by
138 @param Origin
139 position that rotation axis runs through
141 @param bInter
142 see Operation
144 @param T0
145 transformation starting time
147 @param T1
148 transformation ending time
151 SScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
152 virtual ~SScale() override {}
153 private:
154 glm::vec3 scale;
155 glm::vec3 origin;
158 std::shared_ptr<SScale>
159 makeSScale(const glm::vec3& Scale, const glm::vec3& Origin,bool bInter, double T0, double T1);
161 /** translation transformation
163 class STranslate: public Operation
165 public:
166 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
168 /** Constructor
170 @param Vector
171 vector to translate
173 @param bInter
174 see Operation
176 @param T0
177 transformation starting time
179 @param T1
180 transformation ending time
183 STranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
184 virtual ~STranslate() override {}
185 private:
186 /** vector to translate by
188 glm::vec3 vector;
191 std::shared_ptr<STranslate>
192 makeSTranslate(const glm::vec3& Vector,bool bInter, double T0, double T1);
194 /** translation transformation
196 class SEllipseTranslate: public Operation
198 public:
199 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
201 /** Constructor
203 @param Vector
204 vector to translate
206 @param bInter
207 see Operation
209 @param T0
210 transformation starting time
212 @param T1
213 transformation ending time
216 SEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
217 virtual ~SEllipseTranslate() override {}
218 private:
219 /** width and length of the ellipse
221 double width, height;
223 /** start and end position on the ellipse <0,1>
225 double startPosition;
226 double endPosition;
229 std::shared_ptr<SEllipseTranslate>
230 makeSEllipseTranslate(double dWidth, double dHeight, double dStartPosition, double dEndPosition, bool bInter, double T0, double T1);
232 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the width of the window.
234 class RotateAndScaleDepthByWidth: public Operation
236 public:
237 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
239 RotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
240 virtual ~RotateAndScaleDepthByWidth() override {}
241 private:
242 glm::vec3 axis;
243 glm::vec3 origin;
244 double angle;
245 bool scale;
248 std::shared_ptr<RotateAndScaleDepthByWidth>
249 makeRotateAndScaleDepthByWidth(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
251 /** Same as SRotate, except the depth is scaled by the width of the slide divided by the height of the window.
253 class RotateAndScaleDepthByHeight: public Operation
255 public:
256 virtual void interpolate(glm::mat4& matrix, double t, double SlideWidthScale, double SlideHeightScale) const override;
258 RotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
259 virtual ~RotateAndScaleDepthByHeight() override {}
260 private:
261 glm::vec3 axis;
262 glm::vec3 origin;
263 double angle;
264 bool scale;
267 std::shared_ptr<RotateAndScaleDepthByHeight>
268 makeRotateAndScaleDepthByHeight(const glm::vec3& Axis,const glm::vec3& Origin,double Angle, bool bScale, bool bInter, double T0, double T1);
270 #endif // INCLUDED_SLIDESHOW_OPERATIONS_HXX_
272 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */