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 INCLUDED_SVX_VIEWPT3D_HXX 21 #define INCLUDED_SVX_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 for projection 35 |* 36 \************************************************************************/ 37 38 enum class ProjectionType { Parallel, Perspective }; 39 40 41 /************************************************************************* 42 |* 43 |* 3D viewport according to PHIGS 44 |* 45 \************************************************************************/ 46 47 class SVX_DLLPUBLIC Viewport3D 48 { 49 protected: 50 basegfx::B3DHomMatrix aViewTf; // the real transformations matrix 51 basegfx::B3DPoint aVRP; // View Reference Point 52 basegfx::B3DVector aVPN; // View Plane Normal 53 basegfx::B3DVector aVUV; // View Up Vector 54 basegfx::B3DPoint aPRP; // Projection Reference Point(View-coordinates) 55 // up to now only the z-coordinate is considered 56 57 ProjectionType eProjection; // kind of the projection 58 tools::Rectangle aDeviceRect; // position and size of the output area 59 60 struct 61 { 62 double X, Y, W, H; // position and size of the view window 63 } aViewWin; // in view coordinates 64 65 basegfx::B3DPoint aViewPoint; //observers position in world coordinates; 66 // is calculated by the transformation 67 bool bTfValid; // flag, if transformation is valid 68 69 public: 70 Viewport3D(); 71 72 void SetVRP(const basegfx::B3DPoint& rNewVRP); 73 void SetVPN(const basegfx::B3DVector& rNewVPN); 74 void SetVUV(const basegfx::B3DVector& rNewVUV); 75 void SetPRP(const basegfx::B3DPoint& rNewPRP); 76 GetVRP() const77 const basegfx::B3DPoint& GetVRP() const { return aVRP; } GetVUV() const78 const basegfx::B3DVector& GetVUV() const { return aVUV; } 79 SetProjection(ProjectionType ePrj)80 void SetProjection(ProjectionType ePrj) 81 { eProjection = ePrj; bTfValid = false; } GetProjection() const82 ProjectionType GetProjection() const { return eProjection; } 83 84 void SetViewWindow(double fX, double fY, double fW, double fH); 85 86 void SetDeviceWindow(const tools::Rectangle& rRect); GetDeviceWindow() const87 const tools::Rectangle& GetDeviceWindow() const { return aDeviceRect; } 88 89 // returns observers position in world coordinates 90 const basegfx::B3DPoint& GetViewPoint(); 91 }; 92 93 #endif // INCLUDED_SVX_VIEWPT3D_HXX 94 95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 96