Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-10-20 |
2 | // Created by: Sergey ZERCHANINOV | |
973c2be1 | 3 | // Copyright (c) 2011-2014 OPEN CASCADE SAS |
b311480e | 4 | // |
973c2be1 | 5 | // This file is part of Open CASCADE Technology software library. |
b311480e | 6 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 12 | // |
973c2be1 | 13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. | |
7fd59977 | 15 | |
2166f0fa | 16 | #include <OpenGl_GraphicDriver.hxx> |
7fd59977 | 17 | |
2166f0fa SK |
18 | #include <NCollection_DataMap.hxx> |
19 | #include <OpenGl_Structure.hxx> | |
20 | #include <OpenGl_CView.hxx> | |
7fd59977 | 21 | |
a1954302 | 22 | void OpenGl_GraphicDriver::DisplayStructure (const Graphic3d_CView& theCView, |
23 | const Handle(Graphic3d_Structure)& theStructure, | |
24 | const Standard_Integer thePriority) | |
2166f0fa | 25 | { |
a1954302 | 26 | const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; |
63bcc448 | 27 | if (aCView == NULL) |
2166f0fa SK |
28 | return; |
29 | ||
a1954302 | 30 | aCView->View->DisplayStructure (theStructure, thePriority); |
7fd59977 | 31 | } |
32 | ||
a1954302 | 33 | void OpenGl_GraphicDriver::EraseStructure (const Graphic3d_CView& theCView, |
34 | const Handle(Graphic3d_Structure)& theStructure) | |
2166f0fa | 35 | { |
a1954302 | 36 | const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; |
37 | if (aCView == NULL) | |
2166f0fa | 38 | return; |
7fd59977 | 39 | |
a1954302 | 40 | aCView->View->EraseStructure (theStructure); |
7fd59977 | 41 | } |
42 | ||
63bcc448 | 43 | void OpenGl_GraphicDriver::RemoveStructure (Handle(Graphic3d_CStructure)& theCStructure) |
2166f0fa | 44 | { |
63bcc448 | 45 | OpenGl_Structure* aStructure = NULL; |
46 | if (!myMapOfStructure.Find (theCStructure->Id, aStructure)) | |
47 | { | |
2166f0fa | 48 | return; |
63bcc448 | 49 | } |
7fd59977 | 50 | |
63bcc448 | 51 | myMapOfStructure.UnBind (theCStructure->Id); |
52 | aStructure->Release (GetSharedContext()); | |
53 | theCStructure.Nullify(); | |
7fd59977 | 54 | } |
55 | ||
63bcc448 | 56 | Handle(Graphic3d_CStructure) OpenGl_GraphicDriver::Structure (const Handle(Graphic3d_StructureManager)& theManager) |
2166f0fa | 57 | { |
63bcc448 | 58 | Handle(OpenGl_Structure) aStructure = new OpenGl_Structure (theManager); |
59 | myMapOfStructure.Bind (aStructure->Id, aStructure.operator->()); | |
60 | return aStructure; | |
7fd59977 | 61 | } |
59f45b7c | 62 | |
63 | //======================================================================= | |
64 | //function : ChangeZLayer | |
65 | //purpose : | |
66 | //======================================================================= | |
67 | ||
68 | void OpenGl_GraphicDriver::ChangeZLayer (const Graphic3d_CStructure& theCStructure, | |
a1954302 | 69 | const Graphic3d_CView& theCView, |
70 | const Graphic3d_ZLayerId theNewLayerId) | |
59f45b7c | 71 | { |
72 | const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView; | |
73 | ||
5e27df78 | 74 | if (!myMapOfStructure.IsBound (theCStructure.Id) || !aCView) |
59f45b7c | 75 | return; |
76 | ||
5e27df78 | 77 | OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id); |
59f45b7c | 78 | |
79 | aCView->View->ChangeZLayer (aStructure, theNewLayerId); | |
80 | } | |
81 | ||
59f45b7c | 82 | //======================================================================= |
83 | //function : UnsetZLayer | |
84 | //purpose : | |
85 | //======================================================================= | |
86 | ||
a1954302 | 87 | void OpenGl_GraphicDriver::UnsetZLayer (const Graphic3d_ZLayerId theLayerId) |
59f45b7c | 88 | { |
5e27df78 | 89 | NCollection_DataMap<Standard_Integer, OpenGl_Structure*>::Iterator aStructIt (myMapOfStructure); |
59f45b7c | 90 | for( ; aStructIt.More (); aStructIt.Next ()) |
91 | { | |
92 | OpenGl_Structure* aStruct = aStructIt.ChangeValue (); | |
a1954302 | 93 | if (aStruct->ZLayer() == theLayerId) |
94 | aStruct->SetZLayer (Graphic3d_ZLayerId_Default); | |
59f45b7c | 95 | } |
96 | } | |
b7cd4ba7 | 97 | |
98 | //======================================================================= | |
99 | //function : ChangePriority | |
100 | //purpose : | |
101 | //======================================================================= | |
102 | void OpenGl_GraphicDriver::ChangePriority (const Graphic3d_CStructure& theCStructure, | |
a1954302 | 103 | const Graphic3d_CView& theCView, |
104 | const Standard_Integer theNewPriority) | |
b7cd4ba7 | 105 | { |
106 | const OpenGl_CView *aCView = (const OpenGl_CView *)theCView.ptrView; | |
107 | ||
108 | if (!myMapOfStructure.IsBound (theCStructure.Id) || !aCView) | |
109 | return; | |
110 | ||
111 | OpenGl_Structure* aStructure = myMapOfStructure.Find (theCStructure.Id); | |
112 | ||
113 | aCView->View->ChangePriority (aStructure, theNewPriority); | |
114 | } |