1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Aspect_Window_HeaderFile
17 #define _Aspect_Window_HeaderFile
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>
33 class Aspect_DisplayConnection;
35 DEFINE_STANDARD_HANDLE(Aspect_Window, Standard_Transient)
38 class Aspect_Window : public Standard_Transient
40 DEFINE_STANDARD_RTTIEXT(Aspect_Window, Standard_Transient)
43 //! Returns True if the window <me> is virtual
44 Standard_EXPORT Standard_Boolean IsVirtual() const;
46 //! Setup the virtual state
47 Standard_EXPORT void SetVirtual (const Standard_Boolean theVirtual);
49 //! Returns window top-left corner.
50 Graphic3d_Vec2i TopLeft() const
52 Graphic3d_Vec2i aTopLeft, aBotRight;
53 Position (aTopLeft.x(), aTopLeft.y(), aBotRight.x(), aBotRight.y());
57 //! Returns window dimensions.
58 Graphic3d_Vec2i Dimensions() const
60 Graphic3d_Vec2i aSize;
61 Size (aSize.x(), aSize.y());
65 //! Returns connection to Display or NULL.
66 const Handle(Aspect_DisplayConnection)& DisplayConnection() const { return myDisplay; }
68 //! Returns the window background.
69 Standard_EXPORT Aspect_Background Background() const;
71 //! Returns the current image background fill mode.
72 Standard_EXPORT Aspect_FillMethod BackgroundFillMethod() const;
74 //! Returns the window gradient background.
75 Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
77 //! Modifies the window background.
78 Standard_EXPORT void SetBackground (const Aspect_Background& theBack);
80 //! Modifies the window background.
81 Standard_EXPORT void SetBackground (const Quantity_Color& theColor);
83 //! Modifies the window gradient background.
84 Standard_EXPORT void SetBackground (const Aspect_GradientBackground& theBackground);
86 //! Modifies the window gradient background.
87 Standard_EXPORT void SetBackground (const Quantity_Color& theFirstColor, const Quantity_Color& theSecondColor, const Aspect_GradientFillMethod theFillMethod);
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;
95 //! Opens the window <me>.
96 Standard_EXPORT virtual void Map() const = 0;
98 //! Closes the window <me>.
99 Standard_EXPORT virtual void Unmap() const = 0;
101 //! Apply the resizing to the window <me>.
102 Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
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;
108 //! Returns The Window RATIO equal to the physical
109 //! WIDTH/HEIGHT dimensions
110 Standard_EXPORT virtual Standard_Real Ratio() const = 0;
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;
115 //! Returns The Window SIZE in PIXEL
116 Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const = 0;
118 //! Returns native Window handle (HWND on Windows, Window with Xlib, and so on)
119 Standard_EXPORT virtual Aspect_Drawable NativeHandle() const = 0;
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;
124 //! Returns native Window FB config (GLXFBConfig on Xlib)
125 Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
127 //! Sets window title.
128 virtual void SetTitle (const TCollection_AsciiString& theTitle) { (void )theTitle; }
130 //! Invalidate entire window content.
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.
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; }
142 //! Return device pixel ratio (logical to backing store scale factor).
143 virtual Standard_Real DevicePixelRatio() const { return 1.0; }
145 //! Convert point from logical units into backing store units.
146 virtual Graphic3d_Vec2d ConvertPointToBacking (const Graphic3d_Vec2d& thePnt) const
148 return thePnt * DevicePixelRatio();
151 //! Convert point from backing store units to logical units.
152 virtual Graphic3d_Vec2d ConvertPointFromBacking (const Graphic3d_Vec2d& thePnt) const
154 return thePnt / DevicePixelRatio();
159 //! Dumps the content of me into the stream
160 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
164 //! Initializes the data of a Window.
165 Standard_EXPORT Aspect_Window();
169 Handle(Aspect_DisplayConnection) myDisplay; //!< Display connection
170 Aspect_Background MyBackground;
171 Aspect_GradientBackground MyGradientBackground;
172 Aspect_FillMethod MyBackgroundFillMethod;
173 Standard_Boolean MyIsVirtual;
177 #endif // _Aspect_Window_HeaderFile