97eea16fb77197a15e4448265a122928a810729f
[occt.git] / src / Draw / Draw_View.hxx
1 // Copyright (c) 2015 OPEN CASCADE SAS
2 //
3 // This file is part of Open CASCADE Technology software library.
4 //
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
10 //
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
13
14 #ifndef Draw_View_Header
15 #define Draw_View_Header
16
17 #include <gp_Trsf.hxx>
18 #include <Draw_Window.hxx>
19
20 class Draw_Viewer;
21
22 class Draw_View : public Draw_Window
23 {
24 public:
25
26   //! Constructor
27   Draw_View(Standard_Integer theId,
28             Draw_Viewer*     theViewer,
29             Standard_Integer theX,
30             Standard_Integer theY,
31             Standard_Integer theWidth,
32             Standard_Integer theHeight);
33
34 #if defined(_WIN32) || defined(__WIN32__)
35   Draw_View(Standard_Integer theId,
36             Draw_Viewer*     theViewer,
37             Standard_Integer theX,
38             Standard_Integer theY,
39             Standard_Integer theWidth,
40             Standard_Integer theHeight,
41             HWND             theWindow);
42 #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
43   Draw_View(Standard_Integer theId,
44             Draw_Viewer*     theViewer,
45             Standard_Integer theX,
46             Standard_Integer theY,
47             Standard_Integer theWidth,
48             Standard_Integer theHeight,
49             NSWindow*        theWindow);
50 #endif
51
52   //! Constructor.
53   Draw_View(Standard_Integer theId,
54             Draw_Viewer*     theViewer,
55             const char*      theTitle);
56
57   //! Destructor.
58   ~Draw_View();
59
60 public: // @name getters and setters
61
62   //! Sets horizontal offset.
63   void SetDx(const Standard_Integer theDx)
64   {
65     myDx = theDx;
66   }
67
68   //! Sets vertical offset.
69   void SetDy(const Standard_Integer theDy)
70   {
71     myDy = theDy;
72   }
73
74   //! Sets parameter of zoom.
75   void SetZoom(const Standard_Real theZoom)
76   {
77     myZoom = theZoom;
78   }
79
80   //! Sets view matrix.
81   void SetMatrix(const gp_Trsf& theMatrix)
82   {
83     myMatrix = theMatrix;
84   }
85
86   //! Sets focal distance.
87   void SetFocalDistance(const Standard_Real theDistance)
88   {
89     myFocalDistance = theDistance;
90   }
91
92   //! Gets horizontal offset.
93   Standard_Integer GetDx() const
94   {
95     return myDx;
96   }
97
98   //! Gets vertical offset.
99   Standard_Integer GetDy() const
100   {
101     return myDy;
102   }
103
104   //! Gets parameter of zoom.
105   Standard_Real GetZoom() const
106   {
107     return myZoom;
108   }
109
110   //! Gets matrix of view.
111   const gp_Trsf& GetMatrix() const
112   {
113     return myMatrix;
114   }
115
116   //! Gets focal distance.
117   Standard_Real GetFocalDistance() const
118   {
119     return myFocalDistance;
120   }
121
122 public: //! @name public inline methods
123
124   //! Returns type of view.
125   const char* Type()
126   {
127     return myType;
128   }
129
130   //! Returns true value if current view in 2D mode.
131   Standard_Boolean Is2D() const
132   {
133     return myIs2D;
134   }
135
136   //! Returns true value if current view in perspective mode.
137   Standard_Real IsPerspective() const
138   {
139     return myIsPers;
140   }
141
142 public: //! @name view API
143
144   //! Initialize view by the type.
145   Standard_Boolean Init(const char* theType);
146
147   //! Transform view matrix.
148   void Transform(const gp_Trsf& theTransformation);
149
150   //! Resets frame of current view.
151   void ResetFrame();
152
153   //! Returns parameters of frame corners.
154   void GetFrame(Standard_Integer& theX0,Standard_Integer& theY0,
155                 Standard_Integer& theX1,Standard_Integer& theY1);
156
157   //! Perform window exposing.
158   void WExpose();
159
160 protected:
161
162   Standard_Integer       myId;
163   Draw_Viewer*           myViewer;
164   char                   myType[5];
165   Standard_Boolean       myIsPers;
166   Standard_Boolean       myIs2D;
167   Standard_Real          myFocalDistance;
168   Standard_Real          myZoom;
169   gp_Trsf                myMatrix;
170   Standard_Integer       myDx;
171   Standard_Integer       myDy;
172   Standard_Integer       myFrameX0;
173   Standard_Integer       myFrameY0;
174   Standard_Integer       myFrameX1;
175   Standard_Integer       myFrameY1;
176 };
177
178 #endif