0026936: Drawbacks of inlining in new type system in OCCT 7.0 -- automatic
[occt.git] / src / Graphic3d / Graphic3d_MarkerImage.hxx
1 // Created on: 2013-06-25
2 // Created by: Dmitry BOBYLEV
3 // Copyright (c) 2013-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 _Graphic3d_MarkerImage_H__
17 #define _Graphic3d_MarkerImage_H__
18
19 #include <TColStd_HArray1OfByte.hxx>
20 #include <Quantity_Parameter.hxx>
21 #include <TCollection_AsciiString.hxx>
22
23 class Image_PixMap;
24
25 //! This class is used to store bitmaps and images for markers rendering.
26 //! It can convert bitmap texture stored in TColStd_HArray1OfByte to Image_PixMap and vice versa.
27 class Graphic3d_MarkerImage : public Standard_Transient
28 {
29 public:
30
31   //! @param theImage - source image
32   Standard_EXPORT Graphic3d_MarkerImage (const Handle(Image_PixMap)& theImage);
33
34   //! Creates marker image from array of bytes
35   //! (method for compatibility with old markers definition).
36   //! @param theBitMap - source bitmap stored as array of bytes
37   //! @param theWidth  - number of bits in a row
38   //! @param theHeight - number of bits in a column
39   Standard_EXPORT Graphic3d_MarkerImage (const Handle(TColStd_HArray1OfByte)& theBitMap,
40                                          const Standard_Integer& theWidth,
41                                          const Standard_Integer& theHeight);
42
43   //! @param theAlphaValue pixels in the image that have alpha value greater than
44   //!                      or equal to this parameter will be stored in bitmap as "1",
45   //!                      others will be stored as "0"
46   //! @return marker image as array of bytes. If an instance of the class has been
47   //! initialized with image, it will be converted to bitmap based on the parameter theAlphaValue.
48   Standard_EXPORT Handle(TColStd_HArray1OfByte) GetBitMapArray (const Standard_Real& theAlphaValue = 0.5) const;
49
50   //! @return marker image. If an instance of the class has been initialized with a bitmap, it will be
51   //! converted to image.
52   Standard_EXPORT const Handle(Image_PixMap)& GetImage();
53
54   //! @return image alpha as grayscale image. Note that if an instance of the class has been initialized
55   //! with a bitmap or with grayscale image this method will return exactly the same image as GetImage()
56   Standard_EXPORT const Handle(Image_PixMap)& GetImageAlpha();
57
58   //! @return an unique ID. This ID will be used to manage resource in graphic driver.
59   Standard_EXPORT const TCollection_AsciiString& GetImageId() const;
60
61   //! @return an unique ID. This ID will be used to manage resource in graphic driver.
62   Standard_EXPORT const TCollection_AsciiString& GetImageAlphaId() const;
63
64   //! @return texture size
65   Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth,
66                                        Standard_Integer& theHeight) const;
67
68 private:
69
70   TCollection_AsciiString       myImageId;      //!< resource identifier
71   TCollection_AsciiString       myImageAlphaId; //!< resource identifier
72   Handle(TColStd_HArray1OfByte) myBitMap;       //!< bytes array with bitmap definition (for compatibility with old code)
73   Handle(Image_PixMap)          myImage;        //!< full-color  marker definition
74   Handle(Image_PixMap)          myImageAlpha;   //!< alpha-color marker definition (for dynamic hi-lighting)
75   Standard_Integer              myMargin;       //!< extra margin from boundaries for bitmap -> point sprite conversion, 1 px by default
76   Standard_Integer              myWidth;        //!< marker width
77   Standard_Integer              myHeight;       //!< marker height
78
79 public:
80
81   DEFINE_STANDARD_RTTIEXT(Graphic3d_MarkerImage,Standard_Transient) // Type definition
82
83 };
84
85 DEFINE_STANDARD_HANDLE (Graphic3d_MarkerImage, Standard_Transient)
86
87 #endif // _Graphic3d_MarkerImage_H__