Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:14:51

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 <NCollection_Vec2.hxx>
0028 #include <Standard_TypeDef.hxx>
0029 #include <Standard.hxx>
0030 #include <Standard_Transient.hxx>
0031 #include <Standard_Type.hxx>
0032 #include <TCollection_AsciiString.hxx>
0033 
0034 class Aspect_DisplayConnection;
0035 
0036 //! Defines a window.
0037 class Aspect_Window : public Standard_Transient
0038 {
0039   DEFINE_STANDARD_RTTIEXT(Aspect_Window, Standard_Transient)
0040 public:
0041   //! Returns True if the window <me> is virtual
0042   Standard_EXPORT bool IsVirtual() const;
0043 
0044   //! Setup the virtual state
0045   Standard_EXPORT void SetVirtual(const bool theVirtual);
0046 
0047   //! Returns window top-left corner.
0048   NCollection_Vec2<int> TopLeft() const
0049   {
0050     NCollection_Vec2<int> aTopLeft, aBotRight;
0051     Position(aTopLeft.x(), aTopLeft.y(), aBotRight.x(), aBotRight.y());
0052     return aTopLeft;
0053   }
0054 
0055   //! Returns window dimensions.
0056   NCollection_Vec2<int> Dimensions() const
0057   {
0058     NCollection_Vec2<int> aSize;
0059     Size(aSize.x(), aSize.y());
0060     return aSize;
0061   }
0062 
0063   //! Returns connection to Display or NULL.
0064   const occ::handle<Aspect_DisplayConnection>& DisplayConnection() const { return myDisplay; }
0065 
0066   //! Returns the window background.
0067   Standard_EXPORT Aspect_Background Background() const;
0068 
0069   //! Returns the current image background fill mode.
0070   Standard_EXPORT Aspect_FillMethod BackgroundFillMethod() const;
0071 
0072   //! Returns the window gradient background.
0073   Standard_EXPORT Aspect_GradientBackground GradientBackground() const;
0074 
0075   //! Modifies the window background.
0076   Standard_EXPORT void SetBackground(const Aspect_Background& theBack);
0077 
0078   //! Modifies the window background.
0079   Standard_EXPORT void SetBackground(const Quantity_Color& theColor);
0080 
0081   //! Modifies the window gradient background.
0082   Standard_EXPORT void SetBackground(const Aspect_GradientBackground& theBackground);
0083 
0084   //! Modifies the window gradient background.
0085   Standard_EXPORT void SetBackground(const Quantity_Color&           theFirstColor,
0086                                      const Quantity_Color&           theSecondColor,
0087                                      const Aspect_GradientFillMethod theFillMethod);
0088 
0089 public:
0090   //! Returns True if the window <me> is opened
0091   //! and False if the window is closed.
0092   Standard_EXPORT virtual bool IsMapped() const = 0;
0093 
0094   //! Opens the window <me>.
0095   Standard_EXPORT virtual void Map() const = 0;
0096 
0097   //! Closes the window <me>.
0098   Standard_EXPORT virtual void Unmap() const = 0;
0099 
0100   //! Apply the resizing to the window <me>.
0101   Standard_EXPORT virtual Aspect_TypeOfResize DoResize() = 0;
0102 
0103   //! Apply the mapping change to the window <me>.
0104   //! and returns TRUE if the window is mapped at screen.
0105   Standard_EXPORT virtual bool DoMapping() const = 0;
0106 
0107   //! Returns The Window RATIO equal to the physical
0108   //! WIDTH/HEIGHT dimensions
0109   Standard_EXPORT virtual double Ratio() const = 0;
0110 
0111   //! Returns The Window POSITION in PIXEL
0112   Standard_EXPORT virtual void Position(int& X1, int& Y1, int& X2, int& Y2) const = 0;
0113 
0114   //! Returns The Window SIZE in PIXEL
0115   Standard_EXPORT virtual void Size(int& Width, int& Height) const = 0;
0116 
0117   //! Returns native Window handle (HWND on Windows, Window with Xlib, and so on)
0118   Standard_EXPORT virtual Aspect_Drawable NativeHandle() const = 0;
0119 
0120   //! Returns parent of native Window handle (HWND on Windows, Window with Xlib, and so on)
0121   Standard_EXPORT virtual Aspect_Drawable NativeParentHandle() const = 0;
0122 
0123   //! Returns native Window FB config (GLXFBConfig on Xlib)
0124   Standard_EXPORT virtual Aspect_FBConfig NativeFBConfig() const = 0;
0125 
0126   //! Sets window title.
0127   virtual void SetTitle(const TCollection_AsciiString& theTitle) { (void)theTitle; }
0128 
0129   //! Invalidate entire window content.
0130   //!
0131   //! Implementation is expected to allow calling this method from non-GUI thread,
0132   //! e.g. by queuing exposure event into window message queue or in other thread-safe manner.
0133   //!
0134   //! Optional display argument should be passed when called from non-GUI thread
0135   //! on platforms implementing thread-unsafe connections to display.
0136   //! NULL can be passed instead otherwise.
0137   virtual void InvalidateContent(const occ::handle<Aspect_DisplayConnection>& theDisp)
0138   {
0139     (void)theDisp;
0140   }
0141 
0142 public:
0143   //! Return device pixel ratio (logical to backing store scale factor).
0144   virtual double DevicePixelRatio() const { return 1.0; }
0145 
0146   //! Convert point from logical units into backing store units.
0147   virtual NCollection_Vec2<double> ConvertPointToBacking(
0148     const NCollection_Vec2<double>& thePnt) const
0149   {
0150     return thePnt * DevicePixelRatio();
0151   }
0152 
0153   //! Convert point from backing store units to logical units.
0154   virtual NCollection_Vec2<double> ConvertPointFromBacking(
0155     const NCollection_Vec2<double>& thePnt) const
0156   {
0157     return thePnt / DevicePixelRatio();
0158   }
0159 
0160 public:
0161   //! Dumps the content of me into the stream
0162   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0163 
0164 protected:
0165   //! Initializes the data of a Window.
0166   Standard_EXPORT Aspect_Window();
0167 
0168 protected:
0169   occ::handle<Aspect_DisplayConnection> myDisplay; //!< Display connection
0170   Aspect_Background                     MyBackground;
0171   Aspect_GradientBackground             MyGradientBackground;
0172   Aspect_FillMethod                     MyBackgroundFillMethod;
0173   bool                                  MyIsVirtual;
0174 };
0175 
0176 #endif // _Aspect_Window_HeaderFile