0024752: Visualization - inherit OpenGl_Group from Graphic3d_Group
[occt.git] / src / Graphic3d / Graphic3d_AspectMarker3d.cxx
1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-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 #include <Graphic3d_AspectMarker3d.ixx>
17 #include <TColStd_Array1OfByte.hxx>
18 #include <Image_PixMap.hxx>
19 #include <Graphic3d_MarkerImage.hxx>
20
21 // =======================================================================
22 // function : Graphic3d_AspectMarker3d
23 // purpose  :
24 // =======================================================================
25 Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d()
26 : Aspect_AspectMarker()
27 {}
28
29 // =======================================================================
30 // function : Graphic3d_AspectMarker3d
31 // purpose  :
32 // =======================================================================
33 Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Aspect_TypeOfMarker theType,
34                                                     const Quantity_Color&     theColor,
35                                                     const Standard_Real       theScale)
36 : Aspect_AspectMarker (theColor, theType, theScale)
37 {}
38
39 // =======================================================================
40 // function : Graphic3d_AspectMarker3d
41 // purpose  :
42 // =======================================================================
43 Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Quantity_Color&  theColor,
44                                                     const Standard_Integer theWidth,
45                                                     const Standard_Integer theHeight,
46                                                     const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
47 : Aspect_AspectMarker (theColor, Aspect_TOM_USERDEFINED, 1.0),
48   myMarkerImage (new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight))
49 {}
50
51 // =======================================================================
52 // function : Graphic3d_AspectMarker3d
53 // purpose  :
54 // =======================================================================
55 Graphic3d_AspectMarker3d::Graphic3d_AspectMarker3d (const Handle(Image_PixMap)& theTextureImage)
56 : Aspect_AspectMarker (Quantity_NOC_YELLOW, Aspect_TOM_USERDEFINED, 1.0),
57   myMarkerImage (new Graphic3d_MarkerImage (theTextureImage))
58 {}
59
60 // =======================================================================
61 // function : GetTextureSize
62 // purpose  :
63 // =======================================================================
64 void Graphic3d_AspectMarker3d::GetTextureSize (Standard_Integer& theWidth,
65                                                Standard_Integer& theHeight) const
66 {
67   if (!myMarkerImage.IsNull())
68   {
69     myMarkerImage->GetTextureSize (theWidth, theHeight);
70   }
71   else
72   {
73     theWidth  = 0;
74     theHeight = 0;
75   }
76 }
77
78 // =======================================================================
79 // function : GetMarkerImage
80 // purpose  :
81 // =======================================================================
82 const Handle(Graphic3d_MarkerImage)& Graphic3d_AspectMarker3d::GetMarkerImage() const
83 {
84   return myMarkerImage;
85 }
86
87 // =======================================================================
88 // function : SetMarkerImage
89 // purpose  :
90 // =======================================================================
91 void Graphic3d_AspectMarker3d::SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage)
92 {
93   myMarkerImage = theImage;
94 }
95
96 // =======================================================================
97 // function : SetBitMap
98 // purpose  :
99 // =======================================================================
100 void Graphic3d_AspectMarker3d::SetBitMap (const Standard_Integer theWidth,
101                                           const Standard_Integer theHeight,
102                                           const Handle(TColStd_HArray1OfByte)& theTextureBitMap)
103 {
104   myMarkerImage.Nullify();
105   myMarkerImage = new Graphic3d_MarkerImage (theTextureBitMap, theWidth, theHeight);
106 }
107
108 // =======================================================================
109 // function : SetShaderProgram
110 // purpose  :
111 // =======================================================================
112 void Graphic3d_AspectMarker3d::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram)
113 {
114   MyShaderProgram = theProgram;
115 }
116
117 // =======================================================================
118 // function : ShaderProgram
119 // purpose  :
120 // =======================================================================
121 const Handle(Graphic3d_ShaderProgram)& Graphic3d_AspectMarker3d::ShaderProgram() const
122 {
123   return MyShaderProgram;
124 }