Commit | Line | Data |
---|---|---|
2166f0fa SK |
1 | // File: OpenGl_GraphicDriver_4.cxx |
2 | // Created: 20 October 2011 | |
3 | // Author: Sergey ZERCHANINOV | |
4 | // Copyright: OPEN CASCADE 2011 | |
7fd59977 | 5 | |
2166f0fa | 6 | #include <OpenGl_GraphicDriver.hxx> |
7fd59977 | 7 | |
2166f0fa SK |
8 | #include <NCollection_DataMap.hxx> |
9 | #include <OpenGl_Structure.hxx> | |
10 | #include <OpenGl_CView.hxx> | |
7fd59977 | 11 | |
2166f0fa SK |
12 | void OpenGl_GraphicDriver::ClearStructure (const Graphic3d_CStructure& theCStructure) |
13 | { | |
14 | OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure; | |
15 | if (aStructure == NULL) | |
16 | return; | |
7fd59977 | 17 | |
2166f0fa SK |
18 | aStructure->Clear(); |
19 | InvalidateAllWorkspaces(); | |
20 | } | |
7fd59977 | 21 | |
2166f0fa SK |
22 | void OpenGl_GraphicDriver::ContextStructure (const Graphic3d_CStructure& theCStructure) |
23 | { | |
24 | OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure; | |
25 | if (aStructure == NULL) | |
26 | return; | |
7fd59977 | 27 | |
2166f0fa | 28 | aStructure->SetTransformPersistence (theCStructure.TransformPersistence); |
7fd59977 | 29 | |
2166f0fa SK |
30 | if (theCStructure.ContextLine.IsDef) |
31 | aStructure->SetAspectLine (theCStructure.ContextLine); | |
7fd59977 | 32 | |
2166f0fa SK |
33 | if (theCStructure.ContextFillArea.IsDef) |
34 | aStructure->SetAspectFace (theCStructure.ContextFillArea); | |
7fd59977 | 35 | |
2166f0fa SK |
36 | if (theCStructure.ContextMarker.IsDef) |
37 | aStructure->SetAspectMarker (theCStructure.ContextMarker); | |
7fd59977 | 38 | |
2166f0fa SK |
39 | if (theCStructure.ContextText.IsDef) |
40 | aStructure->SetAspectText (theCStructure.ContextText); | |
7fd59977 | 41 | |
2166f0fa | 42 | InvalidateAllWorkspaces(); |
7fd59977 | 43 | } |
44 | ||
2166f0fa SK |
45 | void OpenGl_GraphicDriver::Connect (const Graphic3d_CStructure& theFather, |
46 | const Graphic3d_CStructure& theSon) | |
47 | { | |
48 | OpenGl_Structure* aFather = (OpenGl_Structure* )theFather.ptrStructure; | |
49 | OpenGl_Structure* aSon = (OpenGl_Structure* )theSon.ptrStructure; | |
50 | if (aFather && aSon) | |
51 | aFather->Connect(aSon); | |
7fd59977 | 52 | } |
53 | ||
2166f0fa SK |
54 | void OpenGl_GraphicDriver::Disconnect (const Graphic3d_CStructure& theFather, |
55 | const Graphic3d_CStructure& theSon) | |
56 | { | |
57 | OpenGl_Structure* aFather = (OpenGl_Structure* )theFather.ptrStructure; | |
58 | OpenGl_Structure* aSon = (OpenGl_Structure* )theSon.ptrStructure; | |
59 | if (aFather && aSon) | |
60 | aFather->Disconnect(aSon); | |
7fd59977 | 61 | } |
62 | ||
2166f0fa SK |
63 | void OpenGl_GraphicDriver::DisplayStructure (const Graphic3d_CView& theCView, |
64 | const Graphic3d_CStructure& theCStructure, | |
65 | const Standard_Integer thePriority) | |
66 | { | |
67 | const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; | |
68 | OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure; | |
69 | if (aCView == NULL || aStructure == NULL) | |
70 | return; | |
71 | ||
72 | aCView->View->DisplayStructure (aStructure, thePriority); | |
73 | aCView->WS->Invalidate(); | |
7fd59977 | 74 | } |
75 | ||
2166f0fa SK |
76 | void OpenGl_GraphicDriver::EraseStructure (const Graphic3d_CView& theCView, |
77 | const Graphic3d_CStructure& theCStructure) | |
78 | { | |
79 | const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView; | |
80 | OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure; | |
81 | if (aCView == NULL || aStructure == NULL) | |
82 | return; | |
7fd59977 | 83 | |
2166f0fa SK |
84 | aCView->View->EraseStructure (aStructure); |
85 | aCView->WS->Invalidate(); | |
7fd59977 | 86 | } |
87 | ||
2166f0fa SK |
88 | void OpenGl_GraphicDriver::RemoveStructure (const Graphic3d_CStructure& theCStructure) |
89 | { | |
90 | if (!GetMapOfStructures().IsBound (theCStructure.Id)) | |
91 | return; | |
7fd59977 | 92 | |
2166f0fa SK |
93 | OpenGl_Structure* aStructure = OpenGl_GraphicDriver::GetMapOfStructures().Find (theCStructure.Id); |
94 | OpenGl_GraphicDriver::GetMapOfStructures().UnBind (theCStructure.Id); | |
95 | delete aStructure; | |
96 | InvalidateAllWorkspaces(); | |
7fd59977 | 97 | } |
98 | ||
2166f0fa SK |
99 | void OpenGl_GraphicDriver::Structure (Graphic3d_CStructure& theCStructure) |
100 | { | |
101 | RemoveStructure (theCStructure); | |
7fd59977 | 102 | |
2166f0fa | 103 | OpenGl_Structure* aStructure = new OpenGl_Structure(); |
7fd59977 | 104 | |
2166f0fa SK |
105 | aStructure->SetDegenerateModel (theCStructure.ContextFillArea.DegenerationMode, |
106 | theCStructure.ContextFillArea.SkipRatio); | |
7fd59977 | 107 | |
2166f0fa SK |
108 | Standard_Integer aStatus = 0; |
109 | if (theCStructure.highlight) aStatus |= OPENGL_NS_HIGHLIGHT; | |
110 | if (!theCStructure.visible) aStatus |= OPENGL_NS_HIDE; | |
111 | if (theCStructure.pick) aStatus |= OPENGL_NS_PICK; | |
112 | aStructure->SetNamedStatus (aStatus); | |
7fd59977 | 113 | |
2166f0fa SK |
114 | theCStructure.ptrStructure = aStructure; |
115 | OpenGl_GraphicDriver::GetMapOfStructures().Bind (theCStructure.Id, aStructure); | |
116 | InvalidateAllWorkspaces(); | |
7fd59977 | 117 | } |