Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / viewpt3d.hxx
blobe546f20643a05b9b047de780283a75e95f819f44
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_SVX_VIEWPT3D_HXX
21 #define INCLUDED_SVX_VIEWPT3D_HXX
23 #include <svx/svxdllapi.h>
24 #include <basegfx/matrix/b3dhommatrix.hxx>
25 #include <basegfx/point/b3dpoint.hxx>
26 #include <basegfx/vector/b3dvector.hxx>
27 #include <tools/gen.hxx>
29 // predefines
30 namespace basegfx { class B3DRange; } // end of namespace basegfx
32 /*************************************************************************
34 |* enums for projection and aspect ratio
36 \************************************************************************/
38 enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE };
39 enum AspectMapType { AS_NO_MAPPING, AS_HOLD_SIZE, AS_HOLD_X, AS_HOLD_Y };
42 /*************************************************************************
44 |* 3D-Viewport nach PHIGS
46 \************************************************************************/
48 class SVX_DLLPUBLIC Viewport3D
50 protected:
51 basegfx::B3DHomMatrix aViewTf; // the real transformations matrix
52 basegfx::B3DPoint aVRP; // View Reference Point
53 basegfx::B3DVector aVPN; // View Plane Normal
54 basegfx::B3DVector aVUV; // View Up Vector
55 basegfx::B3DPoint aPRP; // Projection Reference Point(View-coordinates)
56 // up to now only the z-coordinate is considered
57 double fVPD; // View Plane Distance
58 double fNearClipDist; // distance of the near Clipping level
59 double fFarClipDist; // distance of the far Clipping level
61 ProjectionType eProjection; // kind of the projection
62 AspectMapType eAspectMapping; // flag for the acclimatization of the aspect ratio
63 // for display on the device
64 Rectangle aDeviceRect; // position and size of the output area
66 struct
68 double X, Y, W, H; // position and size of the view window
69 } aViewWin; // in view coordinates
71 basegfx::B3DPoint aViewPoint; //observers position in world coordinates;
72 // is calculated by the transformation
73 bool bTfValid; // flag, if transformation is valid
75 double fWRatio; // device/view aspect ratio
76 double fHRatio;
78 void MakeTransform();
80 public:
81 Viewport3D();
83 void SetVRP(const basegfx::B3DPoint& rNewVRP);
84 void SetVPN(const basegfx::B3DVector& rNewVPN);
85 void SetVUV(const basegfx::B3DVector& rNewVUV);
86 void SetPRP(const basegfx::B3DPoint& rNewPRP);
87 void SetVPD(double fNewVPD);
89 const basegfx::B3DPoint& GetVRP() const { return aVRP; }
90 const basegfx::B3DVector& GetVPN() const { return aVPN; }
91 const basegfx::B3DVector& GetVUV() const { return aVUV; }
92 const basegfx::B3DPoint& GetPRP() const { return aPRP; }
93 double GetVPD() const { return fVPD; }
94 double GetNearClipDist() const { return fNearClipDist; }
95 double GetFarClipDist() const { return fFarClipDist; }
97 void SetProjection(ProjectionType ePrj)
98 { eProjection = ePrj; bTfValid = false; }
99 ProjectionType GetProjection() const { return eProjection; }
101 void SetAspectMapping(AspectMapType eAsp)
102 { eAspectMapping = eAsp; bTfValid = false; }
103 AspectMapType GetAspectMapping() { return eAspectMapping; }
105 void SetViewWindow(double fX, double fY, double fW, double fH);
107 void SetDeviceWindow(const Rectangle& rRect);
108 const Rectangle& GetDeviceWindow() const { return aDeviceRect; }
110 // returns observers position in world coordinates
111 const basegfx::B3DPoint& GetViewPoint();
114 #endif // INCLUDED_SVX_VIEWPT3D_HXX
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */