1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: viewpt3d.hxx,v $
10 * $Revision: 1.3.226.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #include "svx/svxdllapi.h"
35 #include <basegfx/matrix/b3dhommatrix.hxx>
36 #include <basegfx/point/b3dpoint.hxx>
37 #include <basegfx/vector/b3dvector.hxx>
38 #include <tools/gen.hxx>
41 namespace basegfx
{ class B3DRange
; } // end of namespace basegfx
43 /*************************************************************************
45 |* enums fuer Projektion und Seitenverhaeltnis
47 \************************************************************************/
49 enum ProjectionType
{ PR_PARALLEL
, PR_PERSPECTIVE
};
50 enum AspectMapType
{ AS_NO_MAPPING
, AS_HOLD_SIZE
, AS_HOLD_X
, AS_HOLD_Y
};
53 /*************************************************************************
55 |* 3D-Viewport nach PHIGS
57 \************************************************************************/
59 class SVX_DLLPUBLIC Viewport3D
62 basegfx::B3DHomMatrix aViewTf
; // die eigentliche Transformationsmatrix
63 basegfx::B3DPoint aVRP
; // View Reference Point
64 basegfx::B3DVector aVPN
; // View Plane Normal
65 basegfx::B3DVector aVUV
; // View Up Vector
66 basegfx::B3DPoint aPRP
; // Projection Reference Point(View-Koordinaten)
67 // bisher wird nur die Z-Koordinate beachtet
68 double fVPD
; // View Plane Distance
69 double fNearClipDist
; // Abstand der vorderen Clippingebene
70 double fFarClipDist
; // Abstand der hinteren Clippingebene
72 ProjectionType eProjection
; // Art der Projektion
73 AspectMapType eAspectMapping
; // Flag fuer Seitenverhaeltnis-Anpassung
74 // bei Ausgabe auf das Geraet
75 Rectangle aDeviceRect
; // Position und Groesse des Ausgabebereichs
79 double X
, Y
, W
, H
; // Position und Groesse des View-Windows
80 } aViewWin
; // in View-Koordinaten
82 basegfx::B3DPoint aViewPoint
; // Beobachterstandpunkt in Weltkoordinaten;
83 // wird mit der Transformation berechnet
84 BOOL bTfValid
; // Flag, ob Transformation gueltig ist
86 double fWRatio
; // Device/View-Seitenverhaeltnisse
89 void MakeTransform(void);
94 void SetVRP(const basegfx::B3DPoint
& rNewVRP
);
95 void SetVPN(const basegfx::B3DVector
& rNewVPN
);
96 void SetVUV(const basegfx::B3DVector
& rNewVUV
);
97 void SetPRP(const basegfx::B3DPoint
& rNewPRP
);
98 void SetVPD(double fNewVPD
);
99 void SetNearClipDist(double fNewNCD
);
100 void SetFarClipDist(double fNewFCD
);
102 const basegfx::B3DPoint
& GetVRP() const { return aVRP
; }
103 const basegfx::B3DVector
& GetVPN() const { return aVPN
; }
104 const basegfx::B3DVector
& GetVUV() const { return aVUV
; }
105 const basegfx::B3DPoint
& GetPRP() const { return aPRP
; }
106 double GetVPD() const { return fVPD
; }
107 double GetNearClipDist() const { return fNearClipDist
; }
108 double GetFarClipDist() const { return fFarClipDist
; }
110 void SetProjection(ProjectionType ePrj
)
111 { eProjection
= ePrj
; bTfValid
= FALSE
; }
112 ProjectionType
GetProjection() const { return(eProjection
); }
114 void SetAspectMapping(AspectMapType eAsp
)
115 { eAspectMapping
= eAsp
; bTfValid
= FALSE
; }
116 AspectMapType
GetAspectMapping() { return eAspectMapping
; }
118 void SetViewWindow(double fX
, double fY
, double fW
, double fH
);
119 void GetViewWindow(double& rX
, double& rY
, double& rW
, double& rH
) const;
121 void SetDeviceWindow(const Rectangle
& rRect
);
122 const Rectangle
& GetDeviceWindow() const { return aDeviceRect
; }
124 // Beobachterstandpunkt in Weltkoordinaten zurueckgeben
125 const basegfx::B3DPoint
& GetViewPoint();
127 // View-Transformationen
128 const basegfx::B3DHomMatrix
& GetViewTransform();
130 // Projektion und Mapping
131 basegfx::B3DPoint
DoProjection(const basegfx::B3DPoint
& rVec
) const;
132 basegfx::B3DPoint
MapToDevice(const basegfx::B3DPoint
& rVec
) const;
135 #endif // _VIEWPT3D_HXX