0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[occt.git] / src / Aspect / Aspect_Window.hxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-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 _Aspect_Window_HeaderFile
17 #define _Aspect_Window_HeaderFile
18
19 #include <Aspect_Background.hxx>
20 #include <Aspect_GradientBackground.hxx>
21 #include <Aspect_FBConfig.hxx>
22 #include <Aspect_FillMethod.hxx>
23 #include <Quantity_Color.hxx>
24 #include <Aspect_GradientFillMethod.hxx>
25 #include <Aspect_TypeOfResize.hxx>
26 #include <Aspect_Drawable.hxx>
27 #include <Graphic3d_Vec2.hxx>
28 #include <Standard.hxx>
29 #include <Standard_Transient.hxx>
30 #include <Standard_Type.hxx>
31 #include <TCollection_AsciiString.hxx>
32
33 class Aspect_DisplayConnection;
34
35 DEFINE_STANDARD_HANDLE(Aspect_Window, Standard_Transient)
36
37 //! Defines a window.
38 class Aspect_Window : public Standard_Transient
39 {
40   DEFINE_STANDARD_RTTIEXT(Aspect_Window, Standard_Transient)
41 public:
42
43   //! Returns True if the window <me> is virtual
44   Standard_EXPORT Standard_Boolean IsVirtual() const;
45
46   //! Setup the virtual state
47   Standard_EXPORT void SetVirtual (const Standard_Boolean theVirtual);
48
49   //! Returns window top-left corner.
50   Graphic3d_Vec2i TopLeft() const
51   {
52     Graphic3d_Vec2i aTopLeft, aBotRight;
53     Position (aTopLeft.x(), aTopLeft.y(), aBotRight.x(), aBotRight.y());
54     return aTopLeft;
55   }
56
57   //! Returns window dimensions.
58   Graphic3d_Vec2i Dimensions() const
59   {
60     Graphic3d_Vec2i aSize;
61     Size (aSize.x(), aSize.y());
62     return aSize;
63   }
64
65   //! Returns connection to Display or NULL.
66   const Handle(Aspect_DisplayConnection)& DisplayConnection() const { return myDisplay; }
67
68   //! Returns the window background.
69   Standard_EXPORT Aspect_Background Background() const;
70
71   //! Returns the current image background fill mode.
72   Standard_EXPORT Aspect_FillMethod BackgroundFillMethod() const;
73
74   //! Returns the window gradient background.
75   Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
76
77   //! Modifies the window background.
78   Standard_EXPORT void SetBackground (const Aspect_Background& theBack);
79
80   //! Modifies the window background.
81   Standard_EXPORT void SetBackground (const Quantity_Color& theColor);
82
83   //! Modifies the window gradient background.
84   Standard_EXPORT void SetBackground (const Aspect_GradientBackground& theBackground);
85
86   //! Modifies the window gradient background.
87   Standard_EXPORT void SetBackground (const Quantity_Color& theFirstColor, const Quantity_Color& theSecondColor, const Aspect_GradientFillMethod theFillMethod);
88
89 public:
90
91   //! Returns True if the window <me> is opened
92   //! and False if the window is closed.
93   Standard_EXPORT virtual Standard_Boolean IsMapped() const = 0;
94
95   //! Opens the window <me>.
96   Standard_EXPORT virtual void Map() const = 0;
97
98   //! Closes the window <me>.
99   Standard_EXPORT virtual void Unmap() const = 0;
100
101   //! Apply the resizing to the window <me>.
102   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
103
104   //! Apply the mapping change to the window <me>.
105   //! and returns TRUE if the window is mapped at screen.
106   Standard_EXPORT virtual Standard_Boolean DoMapping() const = 0;
107
108   //! Returns The Window RATIO equal to the physical
109   //! WIDTH/HEIGHT dimensions
110   Standard_EXPORT virtual Standard_Real Ratio() const = 0;
111
112   //! Returns The Window POSITION in PIXEL
113   Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const = 0;
114
115   //! Returns The Window SIZE in PIXEL
116   Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const = 0;
117
118   //! Returns native Window handle (HWND on Windows, Window with Xlib, and so on)
119   Standard_EXPORT virtual Aspect_Drawable NativeHandle() const = 0;
120
121   //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
122   Standard_EXPORT virtual Aspect_Drawable NativeParentHandle() const = 0;
123
124   //! Returns native Window FB config (GLXFBConfig on Xlib)
125   Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
126
127   //! Sets window title.
128   virtual void SetTitle (const TCollection_AsciiString& theTitle) { (void )theTitle; }
129
130   //! Invalidate entire window content.
131   //!
132   //! Implementation is expected to allow calling this method from non-GUI thread,
133   //! e.g. by queuing exposure event into window message queue or in other thread-safe manner.
134   //!
135   //! Optional display argument should be passed when called from non-GUI thread
136   //! on platforms implementing thread-unsafe connections to display.
137   //! NULL can be passed instead otherwise.
138   virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp) { (void )theDisp; }
139
140 public:
141
142   //! Return device pixel ratio (logical to backing store scale factor).
143   virtual Standard_Real DevicePixelRatio() const { return 1.0; }
144
145   //! Convert point from logical units into backing store units.
146   virtual Graphic3d_Vec2d ConvertPointToBacking (const Graphic3d_Vec2d& thePnt) const
147   {
148     return thePnt * DevicePixelRatio();
149   }
150
151   //! Convert point from backing store units to logical units.
152   virtual Graphic3d_Vec2d ConvertPointFromBacking (const Graphic3d_Vec2d& thePnt) const
153   {
154     return thePnt / DevicePixelRatio();
155   }
156
157 public:
158
159   //! Dumps the content of me into the stream
160   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
161
162 protected:
163
164   //! Initializes the data of a Window.
165   Standard_EXPORT Aspect_Window();
166
167 protected:
168
169   Handle(Aspect_DisplayConnection) myDisplay; //!< Display connection
170   Aspect_Background MyBackground;
171   Aspect_GradientBackground MyGradientBackground;
172   Aspect_FillMethod MyBackgroundFillMethod;
173   Standard_Boolean MyIsVirtual;
174
175 };
176
177 #endif // _Aspect_Window_HeaderFile