1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-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 <OpenGl_GraphicDriver.hxx>
18 #include <NCollection_DataMap.hxx>
19 #include <OpenGl_Structure.hxx>
20 #include <OpenGl_CView.hxx>
22 void OpenGl_GraphicDriver::DisplayStructure (const Graphic3d_CView& theCView,
23 const Handle(Graphic3d_Structure)& theStructure,
24 const Standard_Integer thePriority)
26 const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
30 aCView->View->DisplayStructure (theStructure, thePriority);
33 void OpenGl_GraphicDriver::EraseStructure (const Graphic3d_CView& theCView,
34 const Handle(Graphic3d_Structure)& theStructure)
36 const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
40 aCView->View->EraseStructure (theStructure);
43 void OpenGl_GraphicDriver::RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure)
45 OpenGl_Structure* aStructure = NULL;
46 if (!myMapOfStructure.Find (theCStructure->Id, aStructure))
51 myMapOfStructure.UnBind (theCStructure->Id);
52 aStructure->Release (GetSharedContext());
53 theCStructure.Nullify();
56 Handle(Graphic3d_CStructure) OpenGl_GraphicDriver::Structure (const Handle(Graphic3d_StructureManager)& theManager)
58 Handle(OpenGl_Structure) aStructure = new OpenGl_Structure (theManager);
59 myMapOfStructure.Bind (aStructure->Id, aStructure.operator->());
63 //=======================================================================
64 //function : ChangeZLayer
66 //=======================================================================
68 void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure,
69 const Graphic3d_CView& theCView,
70 const Graphic3d_ZLayerId theNewLayerId)
72 const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
74 if (!myMapOfStructure.IsBound (theCStructure.Id) || !aCView)
77 OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id);
79 aCView->View->ChangeZLayer (aStructure, theNewLayerId);
82 //=======================================================================
83 //function : UnsetZLayer
85 //=======================================================================
87 void OpenGl_GraphicDriver::UnsetZLayer (const Graphic3d_ZLayerId theLayerId)
89 NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure);
90 for( ; aStructIt.More (); aStructIt.Next ())
92 OpenGl_Structure* aStruct = aStructIt.ChangeValue ();
93 if (aStruct->ZLayer() == theLayerId)
94 aStruct->SetZLayer (Graphic3d_ZLayerId_Default);
98 //=======================================================================
99 //function : ChangePriority
101 //=======================================================================
102 void OpenGl_GraphicDriver::ChangePriority (const Graphic3d_CStructure& theCStructure,
103 const Graphic3d_CView& theCView,
104 const Standard_Integer theNewPriority)
106 const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView;
108 if (!myMapOfStructure.IsBound (theCStructure.Id) || !aCView)
111 OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id);
113 aCView->View->ChangePriority (aStructure, theNewPriority);