0022048: Visualization, AIS_InteractiveContext - single object selection should alway...
[occt.git] / src / Graphic3d / Graphic3d_ViewAffinity.hxx
CommitLineData
a272ed94 1// Created on: 2014-12-18
2// Created by: Kirill Gavrilov
3// Copyright (c) 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_ViewAffinity_HeaderFile
17#define _Graphic3d_ViewAffinity_HeaderFile
18
494782f6 19#include <Standard.hxx>
20#include <Standard_Transient.hxx>
ec357c5c 21#include <Standard_Type.hxx>
a272ed94 22
23//! Structure display state.
24class Graphic3d_ViewAffinity : public Standard_Transient
25{
26public:
27
28 //! Empty constructor.
29 Graphic3d_ViewAffinity()
30 {
c3282ec1 31 SetVisible (Standard_True);
a272ed94 32 }
33
34 //! Return visibility flag.
35 bool IsVisible (const Standard_Integer theViewId) const
36 {
37 const unsigned int aBit = 1 << theViewId;
38 return (myMask & aBit) != 0;
39 }
40
c3282ec1 41 //! Setup visibility flag for all views.
42 void SetVisible (const Standard_Boolean theIsVisible)
43 {
44 ::memset (&myMask, theIsVisible ? 0xFF : 0x00, sizeof(myMask));
45 }
46
a272ed94 47 //! Setup visibility flag.
48 void SetVisible (const Standard_Integer theViewId,
49 const bool theIsVisible)
50 {
51 const unsigned int aBit = 1 << theViewId;
52 if (theIsVisible)
53 {
54 myMask |= aBit;
55 }
56 else
57 {
58 myMask &= ~aBit;
59 }
60 }
61
62private:
63
64 unsigned int myMask; //!< affinity mask
65
66public:
67
92efcf78 68 DEFINE_STANDARD_RTTIEXT(Graphic3d_ViewAffinity,Standard_Transient)
a272ed94 69
70};
71
72DEFINE_STANDARD_HANDLE(Graphic3d_ViewAffinity, Standard_Transient)
73
74#endif // _Graphic3d_ViewAffinity_HeaderFile