add some protocols that don't make sense as floating frame targets
[LibreOffice.git] / include / tools / b3dtrans.hxx
blobb12cb7a655cb677a316c369909726e807756ec02
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_TOOLS_B3DTRANS_HXX
21 #define INCLUDED_TOOLS_B3DTRANS_HXX
23 #define ZBUFFER_DEPTH_RANGE (double(256L * 256L * 256L))
25 #include <config_options.h>
26 #include <basegfx/matrix/b3dhommatrix.hxx>
27 #include <tools/gen.hxx>
28 #include <basegfx/matrix/b2dhommatrix.hxx>
29 #include <basegfx/point/b3dpoint.hxx>
30 #include <basegfx/vector/b3dvector.hxx>
31 #include <tools/toolsdllapi.h>
33 /// Transformation sets for 3D output
34 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dTransformationSet
36 private:
37 // Object Matrix Object -> World
38 basegfx::B3DHomMatrix maObjectTrans;
39 basegfx::B3DHomMatrix maInvObjectTrans;
41 // Orientation Matrix
42 basegfx::B3DHomMatrix maOrientation;
43 basegfx::B3DHomMatrix maInvOrientation;
45 // Projection Matrix
46 basegfx::B3DHomMatrix maProjection;
47 basegfx::B3DHomMatrix maInvProjection;
49 // Texture Matrices
50 basegfx::B2DHomMatrix maTexture;
52 // Parameters for ViewportTransformation
53 basegfx::B3DVector maScale;
54 basegfx::B3DVector maTranslate;
56 // ViewPlane DeviceRectangle (user-defined)
57 double mfLeftBound;
58 double mfRightBound;
59 double mfBottomBound;
60 double mfTopBound;
62 // Aspect ratio of 3D transformation (Y / X)
63 // default: 1:1 -> 1.0
64 // Disable with value 0.0
65 double mfRatio;
67 // Viewport area in logical coordinates
68 tools::Rectangle maViewportRectangle;
69 // Visible area within viewport
70 tools::Rectangle maVisibleRectangle;
72 // Actual coordinates as set by CalcViewport
73 // of visible viewport area (logical coordinates)
74 tools::Rectangle maSetBound;
76 // Flags
77 bool mbPerspective : 1;
78 bool mbProjectionValid : 1;
80 public:
81 B3dTransformationSet();
82 virtual ~B3dTransformationSet();
84 B3dTransformationSet(B3dTransformationSet const &) = default;
85 B3dTransformationSet(B3dTransformationSet &&) = default;
86 B3dTransformationSet & operator =(B3dTransformationSet const &) = default;
87 B3dTransformationSet & operator =(B3dTransformationSet &&) = default;
89 void Reset();
91 /** Set the orientation
93 @param vVRP the View Reference Point (VRP)
94 @param vVPN the View Plane Normal (VPN)
95 @param vVUP the View Up Plane (VUP)
97 void SetOrientation(
98 const basegfx::B3DPoint& rVRP = basegfx::B3DPoint(0.0,0.0,1.0),
99 const basegfx::B3DVector& rVPN = basegfx::B3DVector(0.0,0.0,1.0),
100 const basegfx::B3DVector& rVUP = basegfx::B3DVector(0.0,1.0,0.0));
102 // Projection
103 void SetProjection(const basegfx::B3DHomMatrix& mProject);
104 const basegfx::B3DHomMatrix& GetProjection();
106 // Texture
108 // aspect ratio accessors and the defined method of keeping defined aspect ratio
109 double GetRatio() const { return mfRatio; }
110 void SetRatio(double fNew);
112 // Parameters of ViewportTransformation
113 void SetDeviceRectangle(double fL=-1.0, double fR=1.0,
114 double fB=-1.0, double fT=1.0);
115 double GetDeviceRectangleWidth() const { return mfRightBound - mfLeftBound; }
117 void SetPerspective(bool bNew);
119 void SetViewportRectangle(tools::Rectangle const & rRect, tools::Rectangle const & rVisible);
120 void SetViewportRectangle(tools::Rectangle const & rRect) { SetViewportRectangle(rRect, rRect); }
122 void CalcViewport();
124 // Direct accessors for miscellaneous transformations
125 basegfx::B3DPoint WorldToEyeCoor(const basegfx::B3DPoint& rVec);
126 basegfx::B3DPoint EyeToWorldCoor(const basegfx::B3DPoint& rVec);
128 static void Frustum(
129 basegfx::B3DHomMatrix& rTarget,
130 double fLeft = -1.0, double fRight = 1.0,
131 double fBottom = -1.0, double fTop = 1.0,
132 double fNear = 0.001, double fFar = 1.0);
133 static void Ortho(
134 basegfx::B3DHomMatrix& rTarget,
135 double fLeft = -1.0, double fRight = 1.0,
136 double fBottom = -1.0, double fTop = 1.0,
137 double fNear = 0.0, double fFar = 1.0);
138 static void Orientation(
139 basegfx::B3DHomMatrix& rTarget,
140 const basegfx::B3DPoint& aVRP = basegfx::B3DPoint(0.0,0.0,1.0),
141 basegfx::B3DVector aVPN = basegfx::B3DVector(0.0,0.0,1.0),
142 basegfx::B3DVector aVUP = basegfx::B3DVector(0.0,1.0,0.0));
144 protected:
145 void PostSetObjectTrans();
146 void PostSetOrientation();
147 void PostSetProjection();
149 virtual void DeviceRectangleChange();
152 /** Viewport for B3D
154 Uses a simplified model, in which a point is described using a View
155 Reference Point (VRP).
157 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dViewport : public B3dTransformationSet
159 private:
160 basegfx::B3DPoint aVRP; // View Reference Point
161 basegfx::B3DVector aVPN; // View Plane Normal
162 basegfx::B3DVector aVUV; // View Up Vector
164 public:
165 B3dViewport();
166 virtual ~B3dViewport() override;
168 B3dViewport(B3dViewport const &) = default;
169 B3dViewport(B3dViewport &&) = default;
170 B3dViewport & operator =(B3dViewport const &) = default;
171 B3dViewport & operator =(B3dViewport &&) = default;
173 void SetVUV(const basegfx::B3DVector& rNewVUV);
174 void SetViewportValues(
175 const basegfx::B3DPoint& rNewVRP,
176 const basegfx::B3DVector& rNewVPN,
177 const basegfx::B3DVector& rNewVUV);
179 const basegfx::B3DPoint& GetVRP() const { return aVRP; }
180 const basegfx::B3DVector& GetVPN() const { return aVPN; }
181 const basegfx::B3DVector& GetVUV() const { return aVUV; }
183 protected:
184 void CalcOrientation();
187 // B3D camera
189 class SAL_WARN_UNUSED TOOLS_DLLPUBLIC B3dCamera final : public B3dViewport
191 public:
192 B3dCamera(
193 const basegfx::B3DPoint& rPos = basegfx::B3DPoint(0.0, 0.0, 1.0),
194 const basegfx::B3DVector& rLkAt = basegfx::B3DVector(0.0, 0.0, 0.0),
195 double fFocLen = 35.0, double fBnkAng = 0.0);
196 virtual ~B3dCamera() override;
198 B3dCamera(B3dCamera const &) = default;
199 B3dCamera(B3dCamera &&) = default;
200 B3dCamera & operator =(B3dCamera const &) = default;
201 B3dCamera & operator =(B3dCamera &&) = default;
203 private:
204 void CalcNewViewportValues();
205 void CalcFocalLength();
207 virtual void DeviceRectangleChange() override;
209 basegfx::B3DPoint aPosition;
210 basegfx::B3DVector aLookAt;
211 double fFocalLength;
212 double fBankAngle;
216 #endif
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */