1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _VIEWPT3D_HXX 25 #define _VIEWPT3D_HXX 26 27 #include "svx/svxdllapi.h" 28 #include <basegfx/matrix/b3dhommatrix.hxx> 29 #include <basegfx/point/b3dpoint.hxx> 30 #include <basegfx/vector/b3dvector.hxx> 31 #include <tools/gen.hxx> 32 33 // predefines 34 namespace basegfx { class B3DRange; } // end of namespace basegfx 35 36 /************************************************************************* 37 |* 38 |* enums fuer Projektion und Seitenverhaeltnis 39 |* 40 \************************************************************************/ 41 42 enum ProjectionType { PR_PARALLEL, PR_PERSPECTIVE }; 43 enum AspectMapType { AS_NO_MAPPING, AS_HOLD_SIZE, AS_HOLD_X, AS_HOLD_Y }; 44 45 46 /************************************************************************* 47 |* 48 |* 3D-Viewport nach PHIGS 49 |* 50 \************************************************************************/ 51 52 class SVX_DLLPUBLIC Viewport3D 53 { 54 protected: 55 basegfx::B3DHomMatrix aViewTf; // die eigentliche Transformationsmatrix 56 basegfx::B3DPoint aVRP; // View Reference Point 57 basegfx::B3DVector aVPN; // View Plane Normal 58 basegfx::B3DVector aVUV; // View Up Vector 59 basegfx::B3DPoint aPRP; // Projection Reference Point(View-Koordinaten) 60 // bisher wird nur die Z-Koordinate beachtet 61 double fVPD; // View Plane Distance 62 double fNearClipDist; // Abstand der vorderen Clippingebene 63 double fFarClipDist; // Abstand der hinteren Clippingebene 64 65 ProjectionType eProjection; // Art der Projektion 66 AspectMapType eAspectMapping; // Flag fuer Seitenverhaeltnis-Anpassung 67 // bei Ausgabe auf das Geraet 68 Rectangle aDeviceRect; // Position und Groesse des Ausgabebereichs 69 70 struct 71 { 72 double X, Y, W, H; // Position und Groesse des View-Windows 73 } aViewWin; // in View-Koordinaten 74 75 basegfx::B3DPoint aViewPoint; // Beobachterstandpunkt in Weltkoordinaten; 76 // wird mit der Transformation berechnet 77 sal_Bool bTfValid; // Flag, ob Transformation gueltig ist 78 79 double fWRatio; // Device/View-Seitenverhaeltnisse 80 double fHRatio; 81 82 void MakeTransform(void); 83 84 public: 85 Viewport3D(); 86 87 void SetVRP(const basegfx::B3DPoint& rNewVRP); 88 void SetVPN(const basegfx::B3DVector& rNewVPN); 89 void SetVUV(const basegfx::B3DVector& rNewVUV); 90 void SetPRP(const basegfx::B3DPoint& rNewPRP); 91 void SetVPD(double fNewVPD); 92 void SetNearClipDist(double fNewNCD); 93 void SetFarClipDist(double fNewFCD); 94 GetVRP() const95 const basegfx::B3DPoint& GetVRP() const { return aVRP; } GetVPN() const96 const basegfx::B3DVector& GetVPN() const { return aVPN; } GetVUV() const97 const basegfx::B3DVector& GetVUV() const { return aVUV; } GetPRP() const98 const basegfx::B3DPoint& GetPRP() const { return aPRP; } GetVPD() const99 double GetVPD() const { return fVPD; } GetNearClipDist() const100 double GetNearClipDist() const { return fNearClipDist; } GetFarClipDist() const101 double GetFarClipDist() const { return fFarClipDist; } 102 SetProjection(ProjectionType ePrj)103 void SetProjection(ProjectionType ePrj) 104 { eProjection = ePrj; bTfValid = sal_False; } GetProjection() const105 ProjectionType GetProjection() const { return(eProjection); } 106 SetAspectMapping(AspectMapType eAsp)107 void SetAspectMapping(AspectMapType eAsp) 108 { eAspectMapping = eAsp; bTfValid = sal_False; } GetAspectMapping()109 AspectMapType GetAspectMapping() { return eAspectMapping; } 110 111 void SetViewWindow(double fX, double fY, double fW, double fH); 112 void GetViewWindow(double& rX, double& rY, double& rW, double& rH) const; 113 114 void SetDeviceWindow(const Rectangle& rRect); GetDeviceWindow() const115 const Rectangle& GetDeviceWindow() const { return aDeviceRect; } 116 117 // Beobachterstandpunkt in Weltkoordinaten zurueckgeben 118 const basegfx::B3DPoint& GetViewPoint(); 119 120 // View-Transformationen 121 const basegfx::B3DHomMatrix& GetViewTransform(); 122 123 // Projektion und Mapping 124 basegfx::B3DPoint DoProjection(const basegfx::B3DPoint& rVec) const; 125 basegfx::B3DPoint MapToDevice(const basegfx::B3DPoint& rVec) const; 126 }; 127 128 #endif // _VIEWPT3D_HXX 129