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