0022819: Redesign of OpenGl driver
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_3.cxx
1 // File:      OpenGl_GraphicDriver_3.cxx
2 // Created:   20 October 2011
3 // Author:    Sergey ZERCHANINOV
4 // Copyright: OPEN CASCADE 2011
5
6 #include <OpenGl_GraphicDriver.hxx>
7
8 #include <TColStd_HArray1OfByte.hxx>
9
10 #include <OpenGl_Display.hxx>
11 #include <OpenGl_Structure.hxx>
12
13 void OpenGl_GraphicDriver::ClearGroup (const Graphic3d_CGroup& theCGroup)
14 {
15   if (theCGroup.ptrGroup == NULL)
16     return;
17
18   ((OpenGl_Group* )theCGroup.ptrGroup)->Clear();
19   InvalidateAllWorkspaces();
20 }
21
22 void OpenGl_GraphicDriver::CloseGroup (const Graphic3d_CGroup& )
23 {
24   // Do nothing
25 }
26
27 void OpenGl_GraphicDriver::FaceContextGroup (const Graphic3d_CGroup& theCGroup,
28                                              const Standard_Integer  theNoInsert)
29 {
30   if (!theCGroup.ContextFillArea.IsDef || theCGroup.ptrGroup == NULL)
31     return;
32
33   ((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectFace (theCGroup.ContextFillArea, theNoInsert);
34   InvalidateAllWorkspaces();
35 }
36
37 void OpenGl_GraphicDriver::Group (Graphic3d_CGroup& theCGroup)
38 {
39   OpenGl_Structure* aStructure = (OpenGl_Structure* )theCGroup.Struct->ptrStructure;
40   if (aStructure)
41   {
42     theCGroup.ptrGroup = aStructure->AddGroup();
43     InvalidateAllWorkspaces();
44   }
45 }
46
47 void OpenGl_GraphicDriver::LineContextGroup (const Graphic3d_CGroup& theCGroup,
48                                              const Standard_Integer  theNoInsert)
49 {
50   if (!theCGroup.ContextLine.IsDef || theCGroup.ptrGroup == NULL) return;
51
52   ((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectLine (theCGroup.ContextLine, theNoInsert);
53   InvalidateAllWorkspaces();
54 }
55
56 void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup,
57                                                const Standard_Integer  theNoInsert)
58 {
59   if (!theCGroup.ContextMarker.IsDef || theCGroup.ptrGroup == NULL) return;
60
61   ((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectMarker (theCGroup.ContextMarker, theNoInsert);
62   InvalidateAllWorkspaces();
63 }
64
65 void OpenGl_GraphicDriver::MarkerContextGroup (const Graphic3d_CGroup& theCGroup, 
66                                                const Standard_Integer  theNoInsert,
67                                                const Standard_Integer  theMarkWidth,
68                                                const Standard_Integer  theMarkHeight,
69                                                const Handle(TColStd_HArray1OfByte)& theTexture)
70 {
71   if(!theCGroup.ContextMarker.IsDef)
72     return;
73
74   if (!openglDisplay.IsNull())
75     openglDisplay->AddUserMarker ((int )theCGroup.ContextMarker.Scale, theMarkWidth, theMarkHeight, theTexture);
76
77   if (theCGroup.ptrGroup != NULL)
78   {
79     ((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectMarker (theCGroup.ContextMarker, theNoInsert);
80     InvalidateAllWorkspaces();
81   }
82 }
83
84 void OpenGl_GraphicDriver::OpenGroup (const Graphic3d_CGroup& )
85 {
86   // Do nothing
87 }
88
89 void OpenGl_GraphicDriver::RemoveGroup (const Graphic3d_CGroup& theCGroup)
90 {
91   OpenGl_Structure* aStructure = (OpenGl_Structure* )theCGroup.Struct->ptrStructure;
92   if (aStructure == NULL)
93     return;
94
95   aStructure->RemoveGroup ((const OpenGl_Group* )theCGroup.ptrGroup);
96   InvalidateAllWorkspaces();
97 }
98
99 void OpenGl_GraphicDriver::TextContextGroup (const Graphic3d_CGroup& theCGroup,
100                                              const Standard_Integer  theNoInsert)
101 {
102   if (!theCGroup.ContextText.IsDef || theCGroup.ptrGroup == NULL)
103     return;
104
105   ((OpenGl_Group* )theCGroup.ptrGroup)->SetAspectText (theCGroup.ContextText, theNoInsert);
106   InvalidateAllWorkspaces();
107 }