0026147: Visualization - restore the ability to pick only fully included objects...
[occt.git] / src / SelectMgr / SelectMgr_FrustumBuilder.hxx
CommitLineData
f751596e 1// Created on: 2014-11-24
2// Created by: Varvara POSKONINA
3// Copyright (c) 2005-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _SelectMgr_FrustumBuilder_HeaderFile
17#define _SelectMgr_FrustumBuilder_HeaderFile
18
19#include <Graphic3d_Camera.hxx>
20#include <NCollection_Handle.hxx>
21#include <Precision.hxx>
22#include <SelectMgr_VectorTypes.hxx>
23
24//! The purpose of this class is to provide unified interface for building
25//! selecting frustum depending on current camera projection and orientation
26//! matrices, window size and viewport parameters.
27class SelectMgr_FrustumBuilder
28{
29public:
30 //! Creates new frustum builder with empty matrices
31 SelectMgr_FrustumBuilder();
32
33 ~SelectMgr_FrustumBuilder() {};
34
35 //! Stores current orientation matrix
36 void SetOrientation (const Graphic3d_Mat4d& theOrientation);
37
38 //! Stores current projection matrix
39 void SetProjection (const Graphic3d_Mat4d& theProjection);
40
41 //! Stores current window width and height
42 void SetWindowSize (const Standard_Integer theWidth,
43 const Standard_Integer theHeight);
44
45 //! Stores current viewport coordinates
46 void SetViewport (const Standard_Real theX,
47 const Standard_Real theY,
48 const Standard_Real theWidth,
49 const Standard_Real theHeight);
50
51 void InvalidateViewport();
52
53 //! Calculates signed distance between plane with equation
54 //! theEq and point thePnt
55 Standard_Real SignedPlanePntDist (const SelectMgr_Vec3& theEq,
56 const SelectMgr_Vec3& thePnt) const;
57
f751596e 58 //! Projects 2d screen point onto view frustum plane:
59 //! theZ = 0 - near plane,
60 //! theZ = 1 - far plane
61 SelectMgr_Vec3 ProjectPntOnViewPlane (const Standard_Real& theX,
62 const Standard_Real& theY,
63 const Standard_Real& theZ) const;
64
65private:
66
67 //! Unprojects point from NDC coords to 3d world space
68 SelectMgr_Vec3 unProject (const gp_Pnt& thePnt) const;
69
70private:
71
72 Graphic3d_Mat4d myOrientation;
73 Graphic3d_Mat4d myProjection;
74 Standard_Integer myWidth;
75 Standard_Integer myHeight;
76 NCollection_Vec4<Standard_Real> myViewport;
77 Standard_Boolean myIsViewportSet;
78};
79
80#endif // _SelectMgr_FrustumBuilder_HeaderFile