82d4c0224fb920dbe952bea90090baeb1c25bcd1
[occt.git] / src / NIS / NIS_DrawList.hxx
1 // Created on: 2007-07-09
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-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 NIS_DrawList_HeaderFile
17 #define NIS_DrawList_HeaderFile
18
19 #include <Handle_NIS_View.hxx>
20 #include <Handle_NIS_InteractiveObject.hxx>
21 #include <NCollection_List.hxx>
22
23 class NIS_InteractiveContext;
24 /**
25  * This macro defines that OpenGL draw lists will be allocated as array of 5
26  * integers and any of them would not be deleted unless all interactive objects
27  * in the given drawer are removed.
28  * When the macro is undefined every draw list is created when needed and it is
29  * destroyed when there is no objects to show in this draw list.
30  */
31 //#define ARRAY_LISTS
32
33 /**
34  * Implementation of a set of OpenGL draw lists for a given NIS_Drawer and
35  * given NIS_View. Stored in NIS_Drawer instances.
36  */
37
38 class NIS_DrawList 
39 {
40  public:
41   // ---------- PUBLIC METHODS ----------
42
43
44   /**
45    * Empty constructor.
46    */
47   Standard_EXPORT NIS_DrawList ();
48
49   /**
50    * Constructor
51    */
52   Standard_EXPORT NIS_DrawList (const Handle_NIS_View& theView);
53
54   /**
55    * Destructor.
56    */
57   Standard_EXPORT virtual ~NIS_DrawList ();
58
59   /**
60    * Query the list corresponding to the given type.
61    * @param theType
62    *   Integer value coinciding with the enumerated NIS_Drawer:DrawType.
63    */
64   inline Standard_Integer       GetListID (const Standard_Integer theType) const
65 #ifdef ARRAY_LISTS
66   { return myListID + theType; }
67 #else
68   { return myListID[theType]; }
69 #endif
70
71   /**
72    * Set myListID to 0.
73    * @return
74    *   Previous value of myListID
75    */
76   Standard_EXPORT void ClearListID        (const Standard_Integer theType);
77
78   /**
79    * Set myListID to 0.
80    * @return
81    *   Previous value of myListID
82    */
83   Standard_EXPORT void ClearListID        (const Handle_NIS_View& theView=NULL);
84
85   /**
86    * This method is called to start recording a new list. It must be eventually
87    * followed by EndPrepare.
88    * @param theType
89    *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
90    */
91   Standard_EXPORT virtual void  BeginPrepare   (const Standard_Integer theType);
92
93   /**
94    * This method is called to end recording a new list. It must be preceded
95    * by BeginPrepare.
96    * @param theType
97    *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
98    */
99   Standard_EXPORT virtual void  EndPrepare     (const Standard_Integer theType);
100
101   /**
102    * Call the previously prepared list when the screen is redrawn.
103    * @param theType
104    *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
105    */
106   Standard_EXPORT virtual void  Call           (const Standard_Integer theType);
107
108   /**
109    * Query if the given list should be prepared again.
110    * @param theType
111    *   Integer value coinciding with the enumerated NIS_Drawer::DrawType.
112    */
113   inline Standard_Boolean       IsUpdated (const Standard_Integer theType) const
114   { return myIsUpdated [theType]; }
115
116   /**
117    * Set the flag indicating that the List should be updated (rebuilt).
118    */
119   Standard_EXPORT void          SetUpdated     (const Standard_Integer theType);
120
121   /**
122    * Query if the given list should be processed by Dynamic Hilighting.
123    */
124   inline const NCollection_List<Handle_NIS_InteractiveObject>&
125                                 DynHilightedList() const
126   { return myDynHilighted; }
127   
128   /**
129    * Query the View.
130    */
131   inline const Handle_NIS_View& GetView        () const
132   { return myView; }
133
134   /**
135    * Update the list of Dynamically Hilighted entities.
136    */
137   Standard_EXPORT Standard_Boolean SetDynHilighted
138                                 (const Standard_Boolean              isHilight,
139                                  const Handle_NIS_InteractiveObject& theObj);
140
141  protected:
142   // ---------- PROTECTED METHODS ----------
143   Standard_EXPORT void          SetUpdated      (const Standard_Integer,
144                                                  const Standard_Boolean);
145
146 #ifdef ARRAY_LISTS
147   inline void                   SetListID       (const Standard_Integer theID)
148   { myListID = theID; }
149 #endif
150
151  private:
152   // ---------- PRIVATE METHODS (PROHIBITED) ----------
153  NIS_DrawList             (const NIS_DrawList& theOther);
154  // NIS_DrawList& operator = (const NIS_DrawList& theOther);
155
156  private:
157   // ---------- PRIVATE FIELDS ----------
158
159   Handle_NIS_View                                myView;
160 #ifdef ARRAY_LISTS
161   Standard_Integer                               myListID;
162 #else
163   Standard_Integer                               myListID[5];
164 #endif
165   Standard_Boolean                               myIsUpdated[5];
166   NCollection_List<Handle_NIS_InteractiveObject> myDynHilighted;
167 };
168
169
170 #endif