42cf5bc1 |
1 | // Created on: 1997-07-28 |
2 | // Created by: Pierre CHALAMET |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Graphic3d_TextureRoot_HeaderFile |
18 | #define _Graphic3d_TextureRoot_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TCollection_AsciiString.hxx> |
a13f2dc4 |
24 | #include <Image_PixMap.hxx> |
42cf5bc1 |
25 | #include <OSD_Path.hxx> |
26 | #include <Graphic3d_TypeOfTexture.hxx> |
27 | #include <MMgt_TShared.hxx> |
28 | #include <Standard_Boolean.hxx> |
29 | class Graphic3d_TextureParams; |
30 | class TCollection_AsciiString; |
31 | class OSD_Path; |
32 | |
33 | |
34 | class Graphic3d_TextureRoot; |
35 | DEFINE_STANDARD_HANDLE(Graphic3d_TextureRoot, MMgt_TShared) |
36 | |
37 | //! This is the texture root class enable the dialog with the GraphicDriver allows the loading of texture. |
38 | class Graphic3d_TextureRoot : public MMgt_TShared |
39 | { |
40 | |
41 | public: |
42 | |
43 | |
44 | Standard_EXPORT void Destroy() const; |
45 | ~Graphic3d_TextureRoot() |
46 | { |
47 | Destroy(); |
48 | } |
49 | |
50 | //! Checks if a texture class is valid or not. |
51 | //! @return true if the construction of the class is correct |
52 | Standard_EXPORT virtual Standard_Boolean IsDone() const; |
53 | |
54 | |
55 | //! Returns the full path of the defined texture. |
56 | //! It could be empty path if GetImage() is overridden to load image not from file. |
57 | Standard_EXPORT const OSD_Path& Path() const; |
58 | |
59 | //! @return the texture type. |
60 | Standard_EXPORT Graphic3d_TypeOfTexture Type() const; |
61 | |
62 | |
63 | //! This ID will be used to manage resource in graphic driver. |
64 | //! |
65 | //! Default implementation generates unique ID although inheritors may re-initialize it. |
66 | //! |
67 | //! Multiple Graphic3d_TextureRoot instancies with same ID |
68 | //! will be treated as single texture with different parameters |
69 | //! to optimize memory usage though this will be more natural |
70 | //! to use same instance of Graphic3d_TextureRoot when possible. |
71 | //! |
72 | //! Notice that inheritor may set this ID to empty string. |
73 | //! In this case independent graphical resource will be created |
74 | //! for each instance of Graphic3d_AspectFillArea3d where texture will be used. |
75 | //! |
76 | //! @return texture identifier. |
77 | Standard_EXPORT const TCollection_AsciiString& GetId() const; |
42cf5bc1 |
78 | |
79 | //! This method will be called by graphic driver each time when texture resource should be created. |
80 | //! Default constructors allow defining the texture source as path to texture image or directly as pixmap. |
81 | //! If the source is defined as path, then the image will be dynamically loaded when this method is called |
82 | //! (and no copy will be preserved in this class instance). |
83 | //! Inheritors may dynamically generate the image. |
84 | //! Notice, image data should be in Bottom-Up order (see Image_PixMap::IsTopDown())! |
85 | //! @return the image for texture. |
a13f2dc4 |
86 | Standard_EXPORT virtual Handle(Image_PixMap) GetImage() const; |
87 | |
42cf5bc1 |
88 | //! @return low-level texture parameters |
89 | Standard_EXPORT const Handle(Graphic3d_TextureParams)& GetParams() const; |
90 | |
91 | |
92 | //! The path to textures determined from CSF_MDTVTexturesDirectory or CASROOT environment variables. |
93 | //! @return the root folder with default textures. |
94 | Standard_EXPORT static TCollection_AsciiString TexturesFolder(); |
95 | |
96 | |
97 | |
92efcf78 |
98 | DEFINE_STANDARD_RTTIEXT(Graphic3d_TextureRoot,MMgt_TShared) |
42cf5bc1 |
99 | |
100 | protected: |
101 | |
102 | |
103 | //! Creates a texture from a file |
104 | //! Warning: Note that if <FileName> is NULL the texture must be realized |
105 | //! using LoadTexture(image) method. |
106 | Standard_EXPORT Graphic3d_TextureRoot(const TCollection_AsciiString& theFileName, const Graphic3d_TypeOfTexture theType); |
107 | |
108 | //! Creates a texture from pixmap. |
109 | //! Please note that the implementation expects the image data |
110 | //! to be in Bottom-Up order (see Image_PixMap::IsTopDown()). |
a13f2dc4 |
111 | Standard_EXPORT Graphic3d_TextureRoot(const Handle(Image_PixMap)& thePixmap, const Graphic3d_TypeOfTexture theType); |
42cf5bc1 |
112 | |
113 | Handle(Graphic3d_TextureParams) myParams; |
114 | TCollection_AsciiString myTexId; |
a13f2dc4 |
115 | Handle(Image_PixMap) myPixMap; |
42cf5bc1 |
116 | OSD_Path myPath; |
117 | |
118 | |
119 | private: |
120 | |
121 | |
122 | Graphic3d_TypeOfTexture myType; |
123 | |
124 | |
125 | }; |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | #endif // _Graphic3d_TextureRoot_HeaderFile |