0029337: Visualization, TKOpenGl - visual artifacts on Intel Broadwell GPU
[occt.git] / src / Graphic3d / Graphic3d_AspectMarker3d.hxx
CommitLineData
42cf5bc1 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#ifndef _Graphic3d_AspectMarker3d_HeaderFile
17#define _Graphic3d_AspectMarker3d_HeaderFile
18
b6472664 19#include <Aspect_AspectMarkerDefinitionError.hxx>
20#include <Aspect_TypeOfMarker.hxx>
42cf5bc1 21#include <Graphic3d_MarkerImage.hxx>
22#include <Graphic3d_ShaderProgram.hxx>
b6472664 23#include <Image_PixMap.hxx>
24#include <Standard.hxx>
42cf5bc1 25#include <Standard_Integer.hxx>
b6472664 26#include <Standard_Real.hxx>
27#include <Standard_Type.hxx>
42cf5bc1 28#include <TColStd_HArray1OfByte.hxx>
b6472664 29#include <Quantity_ColorRGBA.hxx>
42cf5bc1 30
b6472664 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.
33class Graphic3d_AspectMarker3d : public Standard_Transient
42cf5bc1 34{
b6472664 35 DEFINE_STANDARD_RTTIEXT(Graphic3d_AspectMarker3d, Standard_Transient)
42cf5bc1 36public:
37
42cf5bc1 38 //! Creates a context table for marker primitives
39 //! defined with the following default values:
40 //!
41 //! Marker type : TOM_X
b6472664 42 //! Color : YELLOW
42cf5bc1 43 //! Scale factor: 1.0
44 Standard_EXPORT Graphic3d_AspectMarker3d();
45
46 Standard_EXPORT Graphic3d_AspectMarker3d(const Aspect_TypeOfMarker theType, const Quantity_Color& theColor, const Standard_Real theScale);
47
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);
51
52 //! Creates a context table for marker primitives
53 //! defined with the specified values.
a13f2dc4 54 Standard_EXPORT Graphic3d_AspectMarker3d(const Handle(Image_PixMap)& theTextureImage);
42cf5bc1 55
b6472664 56 //! Return color.
57 const Quantity_ColorRGBA& ColorRGBA() const { return myColor; }
42cf5bc1 58
b6472664 59 //! Return the color.
60 const Quantity_Color& Color() const { return myColor.GetRGB(); }
42cf5bc1 61
b6472664 62 //! Modifies the color.
63 void SetColor (const Quantity_Color& theColor) { myColor.SetRGB (theColor); }
42cf5bc1 64
b6472664 65 //! Return scale factor.
66 Standard_ShortReal Scale() const { return myScale; }
42cf5bc1 67
b6472664 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)
73 {
74 if (theScale <= 0.0f)
75 {
9775fa61 76 throw Aspect_AspectMarkerDefinitionError("Bad value for MarkerScale");
b6472664 77 }
78 myScale = theScale;
79 }
42cf5bc1 80
b6472664 81 //! Assign scale factor.
82 void SetScale (const Standard_Real theScale) { SetScale ((float )theScale); }
42cf5bc1 83
b6472664 84 //! Return marker type.
85 Aspect_TypeOfMarker Type() const { return myType; }
42cf5bc1 86
b6472664 87 //! Modifies the type of marker.
88 void SetType (const Aspect_TypeOfMarker theType) { myType = theType; }
42cf5bc1 89
b6472664 90 //! Returns marker's texture size.
91 Standard_EXPORT void GetTextureSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
92
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; }
96
97 //! Set marker's image texture.
98 void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; }
42cf5bc1 99
b6472664 100 Standard_EXPORT void SetBitMap (const Standard_Integer theWidth, const Standard_Integer theHeight, const Handle(TColStd_HArray1OfByte)& theTexture);
42cf5bc1 101
b6472664 102 //! Return the program.
103 const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; }
42cf5bc1 104
b6472664 105 //! Sets up OpenGL/GLSL shader program.
106 void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; }
42cf5bc1 107
b6472664 108public:
42cf5bc1 109
b6472664 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
115 {
116 theColor = myColor.GetRGB();
117 theType = myType;
118 theScale = myScale;
119 }
42cf5bc1 120
b6472664 121protected:
42cf5bc1 122
b6472664 123 Handle(Graphic3d_ShaderProgram) myProgram;
124 Handle(Graphic3d_MarkerImage) myMarkerImage;
125 Quantity_ColorRGBA myColor;
126 Aspect_TypeOfMarker myType;
127 Standard_ShortReal myScale;
42cf5bc1 128
b6472664 129};
42cf5bc1 130
b6472664 131DEFINE_STANDARD_HANDLE(Graphic3d_AspectMarker3d, Standard_Transient)
42cf5bc1 132
133#endif // _Graphic3d_AspectMarker3d_HeaderFile