Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:59

0001 // Created by: NW,JPB,CAL
0002 // Copyright (c) 1991-1999 Matra Datavision
0003 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
0015 
0016 #ifndef _Aspect_Window_HeaderFile
0017 #define _Aspect_Window_HeaderFile
0018 
0019 #include <Aspect_Background.hxx>
0020 #include <Aspect_GradientBackground.hxx>
0021 #include <Aspect_FBConfig.hxx>
0022 #include <Aspect_FillMethod.hxx>
0023 #include <Quantity_Color.hxx>
0024 #include <Aspect_GradientFillMethod.hxx>
0025 #include <Aspect_TypeOfResize.hxx>
0026 #include <Aspect_Drawable.hxx>
0027 #include <Graphic3d_Vec2.hxx>
0028 #include <Standard.hxx>
0029 #include <Standard_Transient.hxx>
0030 #include <Standard_Type.hxx>
0031 #include <TCollection_AsciiString.hxx>
0032 
0033 class Aspect_DisplayConnection;
0034 
0035 DEFINE_STANDARD_HANDLE(Aspect_Window, Standard_Transient)
0036 
0037 //! Defines a window.
0038 class Aspect_Window : public Standard_Transient
0039 {
0040   DEFINE_STANDARD_RTTIEXT(Aspect_Window, Standard_Transient)
0041 public:
0042 
0043   //! Returns True if the window <me> is virtual
0044   Standard_EXPORT Standard_Boolean IsVirtual() const;
0045 
0046   //! Setup the virtual state
0047   Standard_EXPORT void SetVirtual (const Standard_Boolean theVirtual);
0048 
0049   //! Returns window top-left corner.
0050   Graphic3d_Vec2i TopLeft() const
0051   {
0052     Graphic3d_Vec2i aTopLeft, aBotRight;
0053     Position (aTopLeft.x(), aTopLeft.y(), aBotRight.x(), aBotRight.y());
0054     return aTopLeft;
0055   }
0056 
0057   //! Returns window dimensions.
0058   Graphic3d_Vec2i Dimensions() const
0059   {
0060     Graphic3d_Vec2i aSize;
0061     Size (aSize.x(), aSize.y());
0062     return aSize;
0063   }
0064 
0065   //! Returns connection to Display or NULL.
0066   const Handle(Aspect_DisplayConnection)& DisplayConnection() const { return myDisplay; }
0067 
0068   //! Returns the window background.
0069   Standard_EXPORT Aspect_Background Background() const;
0070 
0071   //! Returns the current image background fill mode.
0072   Standard_EXPORT Aspect_FillMethod BackgroundFillMethod() const;
0073 
0074   //! Returns the window gradient background.
0075   Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
0076 
0077   //! Modifies the window background.
0078   Standard_EXPORT void SetBackground (const Aspect_Background& theBack);
0079 
0080   //! Modifies the window background.
0081   Standard_EXPORT void SetBackground (const Quantity_Color& theColor);
0082 
0083   //! Modifies the window gradient background.
0084   Standard_EXPORT void SetBackground (const Aspect_GradientBackground& theBackground);
0085 
0086   //! Modifies the window gradient background.
0087   Standard_EXPORT void SetBackground (const Quantity_Color& theFirstColor, const Quantity_Color& theSecondColor, const Aspect_GradientFillMethod theFillMethod);
0088 
0089 public:
0090 
0091   //! Returns True if the window <me> is opened
0092   //! and False if the window is closed.
0093   Standard_EXPORT virtual Standard_Boolean IsMapped() const = 0;
0094 
0095   //! Opens the window <me>.
0096   Standard_EXPORT virtual void Map() const = 0;
0097 
0098   //! Closes the window <me>.
0099   Standard_EXPORT virtual void Unmap() const = 0;
0100 
0101   //! Apply the resizing to the window <me>.
0102   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
0103 
0104   //! Apply the mapping change to the window <me>.
0105   //! and returns TRUE if the window is mapped at screen.
0106   Standard_EXPORT virtual Standard_Boolean DoMapping() const = 0;
0107 
0108   //! Returns The Window RATIO equal to the physical
0109   //! WIDTH/HEIGHT dimensions
0110   Standard_EXPORT virtual Standard_Real Ratio() const = 0;
0111 
0112   //! Returns The Window POSITION in PIXEL
0113   Standard_EXPORT virtual void Position (Standard_Integer& X1, Standard_Integer& Y1, Standard_Integer& X2, Standard_Integer& Y2) const = 0;
0114 
0115   //! Returns The Window SIZE in PIXEL
0116   Standard_EXPORT virtual void Size (Standard_Integer& Width, Standard_Integer& Height) const = 0;
0117 
0118   //! Returns native Window handle (HWND on Windows, Window with Xlib, and so on)
0119   Standard_EXPORT virtual Aspect_Drawable NativeHandle() const = 0;
0120 
0121   //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
0122   Standard_EXPORT virtual Aspect_Drawable NativeParentHandle() const = 0;
0123 
0124   //! Returns native Window FB config (GLXFBConfig on Xlib)
0125   Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
0126 
0127   //! Sets window title.
0128   virtual void SetTitle (const TCollection_AsciiString& theTitle) { (void )theTitle; }
0129 
0130   //! Invalidate entire window content.
0131   //!
0132   //! Implementation is expected to allow calling this method from non-GUI thread,
0133   //! e.g. by queuing exposure event into window message queue or in other thread-safe manner.
0134   //!
0135   //! Optional display argument should be passed when called from non-GUI thread
0136   //! on platforms implementing thread-unsafe connections to display.
0137   //! NULL can be passed instead otherwise.
0138   virtual void InvalidateContent (const Handle(Aspect_DisplayConnection)& theDisp) { (void )theDisp; }
0139 
0140 public:
0141 
0142   //! Return device pixel ratio (logical to backing store scale factor).
0143   virtual Standard_Real DevicePixelRatio() const { return 1.0; }
0144 
0145   //! Convert point from logical units into backing store units.
0146   virtual Graphic3d_Vec2d ConvertPointToBacking (const Graphic3d_Vec2d& thePnt) const
0147   {
0148     return thePnt * DevicePixelRatio();
0149   }
0150 
0151   //! Convert point from backing store units to logical units.
0152   virtual Graphic3d_Vec2d ConvertPointFromBacking (const Graphic3d_Vec2d& thePnt) const
0153   {
0154     return thePnt / DevicePixelRatio();
0155   }
0156 
0157 public:
0158 
0159   //! Dumps the content of me into the stream
0160   Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
0161 
0162 protected:
0163 
0164   //! Initializes the data of a Window.
0165   Standard_EXPORT Aspect_Window();
0166 
0167 protected:
0168 
0169   Handle(Aspect_DisplayConnection) myDisplay; //!< Display connection
0170   Aspect_Background MyBackground;
0171   Aspect_GradientBackground MyGradientBackground;
0172   Aspect_FillMethod MyBackgroundFillMethod;
0173   Standard_Boolean MyIsVirtual;
0174 
0175 };
0176 
0177 #endif // _Aspect_Window_HeaderFile