Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _VIEWPT3D_HXX
21 : #define _VIEWPT3D_HXX
22 :
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>
28 :
29 : // predefines
30 : namespace basegfx { class B3DRange; } // end of namespace basegfx
31 :
32 : /*************************************************************************
33 : |*
34 : |* enums fuer Projektion und Seitenverhaeltnis
35 : |*
36 : \************************************************************************/
37 :
38 : enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE };
39 : enum AspectMapType { AS_NO_MAPPING, AS_HOLD_SIZE, AS_HOLD_X, AS_HOLD_Y };
40 :
41 :
42 : /*************************************************************************
43 : |*
44 : |* 3D-Viewport nach PHIGS
45 : |*
46 : \************************************************************************/
47 :
48 4106 : class SVX_DLLPUBLIC Viewport3D
49 : {
50 : protected:
51 : basegfx::B3DHomMatrix aViewTf; // die eigentliche Transformationsmatrix
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-Koordinaten)
56 : // bisher wird nur die Z-Koordinate beachtet
57 : double fVPD; // View Plane Distance
58 : double fNearClipDist; // Abstand der vorderen Clippingebene
59 : double fFarClipDist; // Abstand der hinteren Clippingebene
60 :
61 : ProjectionType eProjection; // Art der Projektion
62 : AspectMapType eAspectMapping; // Flag fuer Seitenverhaeltnis-Anpassung
63 : // bei Ausgabe auf das Geraet
64 : Rectangle aDeviceRect; // Position und Groesse des Ausgabebereichs
65 :
66 : struct
67 : {
68 : double X, Y, W, H; // Position und Groesse des View-Windows
69 : } aViewWin; // in View-Koordinaten
70 :
71 : basegfx::B3DPoint aViewPoint; // Beobachterstandpunkt in Weltkoordinaten;
72 : // wird mit der Transformation berechnet
73 : sal_Bool bTfValid; // Flag, ob Transformation gueltig ist
74 :
75 : double fWRatio; // Device/View-Seitenverhaeltnisse
76 : double fHRatio;
77 :
78 : void MakeTransform(void);
79 :
80 : public:
81 : Viewport3D();
82 :
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);
88 :
89 422 : const basegfx::B3DPoint& GetVRP() const { return aVRP; }
90 : const basegfx::B3DVector& GetVPN() const { return aVPN; }
91 422 : 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; }
96 :
97 414 : void SetProjection(ProjectionType ePrj)
98 414 : { eProjection = ePrj; bTfValid = sal_False; }
99 1652 : ProjectionType GetProjection() const { return(eProjection); }
100 :
101 : void SetAspectMapping(AspectMapType eAsp)
102 : { eAspectMapping = eAsp; bTfValid = sal_False; }
103 422 : AspectMapType GetAspectMapping() { return eAspectMapping; }
104 :
105 : void SetViewWindow(double fX, double fY, double fW, double fH);
106 :
107 : void SetDeviceWindow(const Rectangle& rRect);
108 826 : const Rectangle& GetDeviceWindow() const { return aDeviceRect; }
109 :
110 : // Beobachterstandpunkt in Weltkoordinaten zurueckgeben
111 : const basegfx::B3DPoint& GetViewPoint();
112 : };
113 :
114 : #endif // _VIEWPT3D_HXX
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|