summaryrefslogtreecommitdiff
path: root/inc/NIS_DrawList.hxx
blob: 5d978a66a82c1160e29f4a684f9e45e286283a3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// File:      NIS_DrawList.hxx
// Created:   09.07.07 21:37
// Author:    Alexander GRIGORIEV
// Copyright: Open Cascade 2007


#ifndef NIS_DrawList_HeaderFile
#define NIS_DrawList_HeaderFile

#include <Handle_NIS_View.hxx>
#include <Handle_NIS_InteractiveObject.hxx>
#include <NCollection_List.hxx>

class NIS_InteractiveContext;
/**
 * This macro defines that OpenGL draw lists will be allocated as array of 5
 * integers and any of them would not be deleted unless all interactive objects
 * in the given drawer are removed.
 * When the macro is undefined every draw list is created when needed and it is
 * destroyed when there is no objects to show in this draw list.
 */
//#define ARRAY_LISTS

/**
 * Implementation of a set of OpenGL draw lists for a given NIS_Drawer and
 * given NIS_View. Stored in NIS_Drawer instances.
 */

class NIS_DrawList 
{
 public:
  // ---------- PUBLIC METHODS ----------


  /**
   * Empty constructor.
   */
  Standard_EXPORT NIS_DrawList ();

  /**
   * Constructor
   */
  Standard_EXPORT NIS_DrawList (const Handle_NIS_View& theView);

  /**
   * Destructor.
   */
  Standard_EXPORT virtual ~NIS_DrawList ();

  /**
   * Query the list corresponding to the given type.
   * @param theType
   *   Integer value coinciding with the enumerated NIS_Drawer:DrawType.
   */
  inline Standard_Integer       GetListID (const Standard_Integer theType) const
#ifdef ARRAY_LISTS
  { return myListID + theType; }
#else
  { return myListID[theType]; }
#endif

  /**
   * Set myListID to 0.
   * @return
   *   Previous value of myListID
   */
  Standard_EXPORT void ClearListID        (const Standard_Integer theType);

  /**
   * Set myListID to 0.
   * @return
   *   Previous value of myListID
   */
  Standard_EXPORT void ClearListID        (const Handle_NIS_View& theView=NULL);

  /**
   * This method is called to start recording a new list. It must be eventually
   * followed by EndPrepare.
   * @param theType
   *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
   */
  Standard_EXPORT virtual void  BeginPrepare   (const Standard_Integer theType);

  /**
   * This method is called to end recording a new list. It must be preceded
   * by BeginPrepare.
   * @param theType
   *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
   */
  Standard_EXPORT virtual void  EndPrepare     (const Standard_Integer theType);

  /**
   * Call the previously prepared list when the screen is redrawn.
   * @param theType
   *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
   */
  Standard_EXPORT virtual void  Call           (const Standard_Integer theType);

  /**
   * Query if the given list should be prepared again.
   * @param theType
   *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
   */
  inline Standard_Boolean       IsUpdated (const Standard_Integer theType) const
  { return myIsUpdated [theType]; }

  /**
   * Set the flag indicating that the List should be updated (rebuilt).
   */
  Standard_EXPORT void          SetUpdated     (const Standard_Integer theType);

  /**
   * Query if the given list should be processed by Dynamic Hilighting.
   */
  inline const NCollection_List<Handle_NIS_InteractiveObject>&
                                DynHilightedList() const
  { return myDynHilighted; }
  
  /**
   * Query the View.
   */
  inline const Handle_NIS_View& GetView        () const
  { return myView; }

  /**
   * Update the list of Dynamically Hilighted entities.
   */
  Standard_EXPORT Standard_Boolean SetDynHilighted
                                (const Standard_Boolean              isHilight,
                                 const Handle_NIS_InteractiveObject& theObj);

 protected:
  // ---------- PROTECTED METHODS ----------
  Standard_EXPORT void          SetUpdated      (const Standard_Integer,
                                                 const Standard_Boolean);

#ifdef ARRAY_LISTS
  inline void                   SetListID       (const Standard_Integer theID)
  { myListID = theID; }
#endif

 private:
  // ---------- PRIVATE METHODS (PROHIBITED) ----------
 NIS_DrawList             (const NIS_DrawList& theOther);
 // NIS_DrawList& operator = (const NIS_DrawList& theOther);

 private:
  // ---------- PRIVATE FIELDS ----------

  Handle_NIS_View                                myView;
#ifdef ARRAY_LISTS
  Standard_Integer                               myListID;
#else
  Standard_Integer                               myListID[5];
#endif
  Standard_Boolean                               myIsUpdated[5];
  NCollection_List<Handle_NIS_InteractiveObject> myDynHilighted;
};


#endif