1 // Created by: NW,JPB,CAL
2 // Copyright (c) 1991-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _Graphic3d_AspectMarker3d_HeaderFile
17 #define _Graphic3d_AspectMarker3d_HeaderFile
19 #include <Aspect_AspectMarkerDefinitionError.hxx>
20 #include <Aspect_TypeOfMarker.hxx>
21 #include <Graphic3d_MarkerImage.hxx>
22 #include <Graphic3d_ShaderProgram.hxx>
23 #include <Image_PixMap.hxx>
24 #include <Standard.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Real.hxx>
27 #include <Standard_Type.hxx>
28 #include <TColStd_HArray1OfByte.hxx>
29 #include <Quantity_ColorRGBA.hxx>
31 //! Creates and updates an attribute group for marker type primitives.
32 //! This group contains the type of marker, its color, and its scale factor.
33 class Graphic3d_AspectMarker3d : public Standard_Transient
35 DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
38 //! Creates a context table for marker primitives
39 //! defined with the following default values:
41 //! Marker type : TOM_X
44 Standard_EXPORT Graphic3d_AspectMarker3d();
46 Standard_EXPORT Graphic3d_AspectMarker3d(const Aspect_TypeOfMarker theType, const Quantity_Color& theColor, const Standard_Real theScale);
48 //! Creates a context table for marker primitives
49 //! defined with the specified values.
50 Standard_EXPORT Graphic3d_AspectMarker3d(const Quantity_Color& theColor, const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTextureBitmap);
52 //! Creates a context table for marker primitives
53 //! defined with the specified values.
54 Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage);
57 const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
60 const Quantity_Color& Color() const { return myColor.GetRGB(); }
62 //! Modifies the color.
63 void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
65 //! Return scale factor.
66 Standard_ShortReal Scale() const { return myScale; }
68 //! Modifies the scale factor.
69 //! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor.
70 //! It is always the smallest displayable dot.
71 //! Warning: Raises AspectMarkerDefinitionError if the scale is a negative value.
72 void SetScale (const Standard_ShortReal theScale)
76 Aspect_AspectMarkerDefinitionError::Raise ("Bad value for MarkerScale");
81 //! Assign scale factor.
82 void SetScale (const Standard_Real theScale) { SetScale ((float )theScale); }
84 //! Return marker type.
85 Aspect_TypeOfMarker Type() const { return myType; }
87 //! Modifies the type of marker.
88 void SetType (const Aspect_TypeOfMarker theType) { myType = theType; }
90 //! Returns marker's texture size.
91 Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
93 //! Returns marker's image texture.
94 //! Could be null handle if marker aspect has been initialized as default type of marker.
95 const Handle(Graphic3d_MarkerImage)& GetMarkerImage() const { return myMarkerImage; }
97 //! Set marker's image texture.
98 void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
100 Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture);
102 //! Return the program.
103 const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
105 //! Sets up OpenGL/GLSL shader program.
106 void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
110 //! Returns the current values of the group.
111 Standard_DEPRECATED("Deprecated method Values() should be replaced by individual property getters")
112 void Values (Quantity_Color& theColor,
113 Aspect_TypeOfMarker& theType,
114 Standard_Real& theScale) const
116 theColor = myColor.GetRGB();
123 Handle(Graphic3d_ShaderProgram) myProgram;
124 Handle(Graphic3d_MarkerImage) myMarkerImage;
125 Quantity_ColorRGBA myColor;
126 Aspect_TypeOfMarker myType;
127 Standard_ShortReal myScale;
131 DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Standard_Transient)
133 #endif // _Graphic3d_AspectMarker3d_HeaderFile