0023186: Unable to display Graphic3d_ArrayOfPoints after migrating from OCCT 6.5.2
[occt.git] / src / OpenGl / OpenGl_GraphicDriver_8.cxx
CommitLineData
b311480e 1// Created on: 2011-10-20
2// Created by: Sergey ZERCHANINOV
3// Copyright (c) 2011-2012 OPEN CASCADE SAS
4//
5// The content of this file is subject to the Open CASCADE Technology Public
6// License Version 6.5 (the "License"). You may not use the content of this file
7// except in compliance with the License. Please obtain a copy of the License
8// at http://www.opencascade.org and read it completely before using this file.
9//
10// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12//
13// The Original Code and all software distributed under the License is
14// distributed on an "AS IS" basis, without warranty of any kind, and the
15// Initial Developer hereby disclaims all such warranties, including without
16// limitation, any warranties of merchantability, fitness for a particular
17// purpose or non-infringement. Please see the License for the specific terms
18// and conditions governing the rights and limitations under the License.
19
7fd59977 20
2166f0fa 21#include <OpenGl_GraphicDriver.hxx>
7fd59977 22
2166f0fa
SK
23#include <OpenGl_CView.hxx>
24#include <OpenGl_Structure.hxx>
7fd59977 25
2166f0fa 26static Handle(OpenGl_Workspace) myImmediateWS;
7fd59977 27
2166f0fa 28/*----------------------------------------------------------------------*/
7fd59977 29
2166f0fa 30Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView)
7fd59977 31{
2166f0fa
SK
32 if (ACView.ViewId == -1)
33 return Standard_False;
7fd59977 34
2166f0fa
SK
35 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
36 if (aCView && aCView->WS->BeginAddMode())
37 {
38 myImmediateWS = aCView->WS;
39 return Standard_True;
7fd59977 40 }
7fd59977 41
2166f0fa 42 return Standard_False;
7fd59977 43}
44
2166f0fa 45void OpenGl_GraphicDriver::EndAddMode (void)
7fd59977 46{
2166f0fa
SK
47 if (!myImmediateWS.IsNull())
48 {
49 myImmediateWS->EndAddMode();
50 myImmediateWS.Nullify();
7fd59977 51 }
7fd59977 52}
53
2166f0fa 54Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode)
7fd59977 55{
2166f0fa
SK
56 if (ACView.ViewId == -1)
57 return Standard_False;
7fd59977 58
2166f0fa
SK
59 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
60 if (aCView && aCView->WS->BeginImmediatMode(ACView, DoubleBuffer, RetainMode))
61 {
62 myImmediateWS = aCView->WS;
63 return Standard_True;
7fd59977 64 }
7fd59977 65
2166f0fa 66 return Standard_False;
7fd59977 67}
68
2166f0fa 69void OpenGl_GraphicDriver::BeginPolyline ()
7fd59977 70{
2166f0fa
SK
71 if (!myImmediateWS.IsNull())
72 myImmediateWS->BeginPolyline();
7fd59977 73}
74
2166f0fa 75void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView, const Standard_Boolean aFlush)
7fd59977 76{
2166f0fa
SK
77 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
78 if (aCView)
79 aCView->WS->ClearImmediatMode(ACView,aFlush);
7fd59977 80}
81
2166f0fa 82void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
7fd59977 83{
2166f0fa
SK
84 if (!myImmediateWS.IsNull())
85 myImmediateWS->Draw(X,Y,Z);
7fd59977 86}
87
2166f0fa
SK
88void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure)
89{
90 OpenGl_Structure *astructure = (OpenGl_Structure *)ACStructure.ptrStructure;
91 if (!astructure)
92 return;
7fd59977 93
2166f0fa
SK
94 if (!myImmediateWS.IsNull())
95 myImmediateWS->DrawStructure(astructure);
7fd59977 96}
97
2166f0fa 98void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize)
7fd59977 99{
2166f0fa
SK
100 if (!myImmediateWS.IsNull())
101 {
102 myImmediateWS->EndImmediatMode();
103 myImmediateWS.Nullify();
7fd59977 104 }
7fd59977 105}
106
2166f0fa 107void OpenGl_GraphicDriver::EndPolyline ()
7fd59977 108{
2166f0fa
SK
109 if (!myImmediateWS.IsNull())
110 myImmediateWS->EndPolyline();
7fd59977 111}
112
2166f0fa 113void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
7fd59977 114{
2166f0fa
SK
115 if (!myImmediateWS.IsNull())
116 myImmediateWS->Move(X,Y,Z);
7fd59977 117}
118
2166f0fa 119void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
7fd59977 120{
2166f0fa
SK
121 if (!myImmediateWS.IsNull())
122 myImmediateWS->SetLineColor(R,G,B);
7fd59977 123}
124
2166f0fa 125void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type)
7fd59977 126{
2166f0fa
SK
127 if (!myImmediateWS.IsNull())
128 myImmediateWS->SetLineType(Type);
7fd59977 129}
130
131void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
132{
2166f0fa
SK
133 if (!myImmediateWS.IsNull())
134 myImmediateWS->SetLineWidth(Width);
7fd59977 135}
136
137void OpenGl_GraphicDriver::SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2)
138{
2166f0fa
SK
139 if (!myImmediateWS.IsNull())
140 myImmediateWS->SetMinMax(X1,Y1,Z1,X2,Y2,Z2);
7fd59977 141}
142
143void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
144{
2166f0fa
SK
145 if (!myImmediateWS.IsNull())
146 myImmediateWS->Transform(AMatrix,AType);
7fd59977 147}