0028201: Add square PConfusion() method to the Precision class
[occt.git] / src / OpenGl / OpenGl_LineAttributes.hxx
CommitLineData
73192b37 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
3// Copyright (c) 2011-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 _OpenGl_LineAttributes_Header
17#define _OpenGl_LineAttributes_Header
18
19#include <OpenGl_Resource.hxx>
20
21#include <Aspect_TypeOfLine.hxx>
22#include <Aspect_TypeOfMarker.hxx>
23#include <Font_FontAspect.hxx>
24
25class OpenGl_Context;
73192b37 26
b6472664 27#define TEL_HS_USER_DEF_START 15
28
6d0e6be5 29//! Utility class to manage OpenGL state of polygon hatching rasterization
30//! and keeping its cached state. The hatching rasterization is implemented
31//! using glPolygonStipple function of OpenGL. State of hatching is controlled
32//! by two parameters - type of hatching and IsEnabled parameter.
33//! The hatching rasterization is enabled only if non-zero index pattern type
34//! is selected (zero by default is reserved for solid filling) and if
35//! IsEnabled flag is set to true. The IsEnabled parameter is useful for temporarily
36//! turning on/off the hatching rasterization without making any costly GL calls
37//! for changing the hatch pattern. This is a sharable resource class - it creates
38//! OpenGL context objects for each hatch pattern to achieve quicker switching between
39//! them, thesse GL objects are freed when the resource is released by owner context.
40//! @note The implementation is not supported by Core Profile and by ES version.
73192b37 41class OpenGl_LineAttributes : public OpenGl_Resource
42{
43public:
44
6d0e6be5 45 //! Default constructor.
46 //! By default the parameters are:
47 //! - IsEnabled (true),
48 //! - TypeOfHatch (0).
73192b37 49 OpenGl_LineAttributes();
6d0e6be5 50
51 //! Default destructor.
73192b37 52 virtual ~OpenGl_LineAttributes();
53
6d0e6be5 54 //! Initialize hatch patterns as GL resources.
55 //! Call this method before using hatching.
56 void Init (const OpenGl_Context* theGlCtx);
57
58 //! Release GL resources.
79104795 59 virtual void Release (OpenGl_Context* theGlCtx) Standard_OVERRIDE;
73192b37 60
6d0e6be5 61 //! Index of currently selected type of hatch.
62 int TypeOfHatch() const { return myTypeOfHatch; }
63
64 //! Sets type of the hatch.
65 int SetTypeOfHatch (const OpenGl_Context* theGlCtx, const int theType);
66
67 //! Current enabled state of the hatching rasterization.
68 bool IsEnabled() const { return myIsEnabled; }
69
70 //! Turns on/off the hatching rasterization rasterization.
71 bool SetEnabled (const OpenGl_Context* theGlCtx, const bool theToEnable);
73192b37 72
73protected:
74
6d0e6be5 75 unsigned int myPatternBase; //!< Base index for predefined hatch patterns
76 int myTypeOfHatch; //!< Currently activated type of hatch
77 bool myIsEnabled; //!< Current enabled state of hatching rasterization.
73192b37 78
79public:
80
92efcf78 81 DEFINE_STANDARD_RTTIEXT(OpenGl_LineAttributes,OpenGl_Resource)
73192b37 82};
83
84DEFINE_STANDARD_HANDLE(OpenGl_LineAttributes, OpenGl_Resource)
85
86#endif // _OpenGl_LineAttributes_Header