1 // Created on: 2007-07-09
2 // Created by: Alexander GRIGORIEV
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <NIS_Drawer.hxx>
17 #include <NIS_View.hxx>
19 #include <OpenGl_GlCore11.hxx>
21 //=======================================================================
22 //function : NIS_DrawList()
23 //purpose : Empty Constructor
24 //=======================================================================
26 NIS_DrawList::NIS_DrawList ()
37 myIsUpdated[0] = Standard_True;
38 myIsUpdated[1] = Standard_True;
39 myIsUpdated[2] = Standard_True;
40 myIsUpdated[3] = Standard_True;
41 myIsUpdated[4] = Standard_True;
44 //=======================================================================
45 //function : NIS_DrawList()
46 //purpose : Constructor
47 //=======================================================================
49 NIS_DrawList::NIS_DrawList (const Handle(NIS_View)& theView)
61 myIsUpdated[0] = Standard_True;
62 myIsUpdated[1] = Standard_True;
63 myIsUpdated[2] = Standard_True;
64 myIsUpdated[3] = Standard_True;
65 myIsUpdated[4] = Standard_True;
68 //=======================================================================
69 //function : ~NIS_DrawList
71 //=======================================================================
73 NIS_DrawList::~NIS_DrawList ()
76 //glDeleteLists (myListID, 5);
79 //=======================================================================
80 //function : ClearListID
81 //purpose : Set myListID to 0.
82 //=======================================================================
84 void NIS_DrawList::ClearListID (const Standard_Integer theType)
88 // To be called only in Callback context (i.e. when GL context is active)
89 if (myListID[theType] > 0) {
90 glDeleteLists(myListID[theType], 1);
91 myListID[theType] = 0;
93 myIsUpdated[theType] = Standard_False;
98 //=======================================================================
99 //function : ClearListID
100 //purpose : Set myListID to 0.
101 //=======================================================================
103 void NIS_DrawList::ClearListID (const Handle(NIS_View)& theView)
107 myView->GetExListId().Add(myListID);
110 NIS_View * pView = (myView.IsNull()) ?
111 theView.operator->() : myView.operator->();
114 pView->GetExListId().Add(myListID[0]);
117 pView->GetExListId().Add(myListID[1]);
120 pView->GetExListId().Add(myListID[2]);
123 pView->GetExListId().Add(myListID[3]);
126 pView->GetExListId().Add(myListID[4]);
131 myIsUpdated[0] = Standard_False;
132 myIsUpdated[1] = Standard_False;
133 myIsUpdated[2] = Standard_False;
134 myIsUpdated[3] = Standard_False;
135 myIsUpdated[4] = Standard_False;
138 //=======================================================================
139 //function : BeginPrepare
141 //=======================================================================
143 void NIS_DrawList::BeginPrepare (const Standard_Integer theType)
147 myListID = glGenLists(5);
149 if (GetListID(theType) == 0)
150 myListID[theType] = glGenLists(1);
152 glNewList (GetListID(theType), GL_COMPILE);
155 //=======================================================================
156 //function : EndPrepare
158 //=======================================================================
160 void NIS_DrawList::EndPrepare (const Standard_Integer theType)
163 myIsUpdated[theType] = Standard_False;
166 //=======================================================================
169 //=======================================================================
171 void NIS_DrawList::Call (const Standard_Integer theType)
173 glCallList (GetListID (theType));
176 //=======================================================================
177 //function : SetDynHilighted
179 //=======================================================================
181 Standard_Boolean NIS_DrawList::SetDynHilighted
182 (const Standard_Boolean isHili,
183 const Handle(NIS_InteractiveObject)& theObj)
185 Standard_Boolean aResult (Standard_False);
186 NCollection_List<Handle(NIS_InteractiveObject)>::Iterator anIt(myDynHilighted);
187 for (; anIt.More(); anIt.Next())
188 if (anIt.Value() == theObj)
191 if (isHili == Standard_False) {
192 myIsUpdated[NIS_Drawer::Draw_DynHilighted] = Standard_True;
193 myDynHilighted.Remove (anIt);
194 aResult = Standard_True;
197 if (isHili == Standard_True) {
198 myIsUpdated[NIS_Drawer::Draw_DynHilighted] = Standard_True;
199 myDynHilighted.Append (theObj);
200 aResult = Standard_True;
205 //=======================================================================
206 //function : SetUpdated
208 //=======================================================================
210 void NIS_DrawList::SetUpdated (const Standard_Integer theType,
211 const Standard_Boolean theFlag)
216 myIsUpdated [theType] = Standard_False;
219 //=======================================================================
220 //function : SetUpdated
222 //=======================================================================
224 void NIS_DrawList::SetUpdated (const Standard_Integer theType)
226 myIsUpdated [theType] = Standard_True;
227 if (theType == NIS_Drawer::Draw_Hilighted)
228 myDynHilighted.Clear();