1 // Created on: 2011-10-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
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.
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.
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.
21 #include <OpenGl_GraphicDriver.hxx>
23 #include <OpenGl_CView.hxx>
24 #include <OpenGl_Structure.hxx>
26 static Handle(OpenGl_Workspace) myImmediateWS;
28 /*----------------------------------------------------------------------*/
30 Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView)
32 if (ACView.ViewId == -1)
33 return Standard_False;
35 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
36 if (aCView && aCView->WS->BeginAddMode())
38 myImmediateWS = aCView->WS;
42 return Standard_False;
45 void OpenGl_GraphicDriver::EndAddMode (void)
47 if (!myImmediateWS.IsNull())
49 myImmediateWS->EndAddMode();
50 myImmediateWS.Nullify();
54 Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode)
56 if (ACView.ViewId == -1)
57 return Standard_False;
59 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
60 if (aCView && aCView->WS->BeginImmediatMode(ACView, DoubleBuffer, RetainMode))
62 myImmediateWS = aCView->WS;
66 return Standard_False;
69 void OpenGl_GraphicDriver::BeginPolyline ()
71 if (!myImmediateWS.IsNull())
72 myImmediateWS->BeginPolyline();
75 void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView, const Standard_Boolean aFlush)
77 const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
79 aCView->WS->ClearImmediatMode(ACView,aFlush);
82 void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
84 if (!myImmediateWS.IsNull())
85 myImmediateWS->Draw(X,Y,Z);
88 void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure)
90 OpenGl_Structure *astructure = (OpenGl_Structure *)ACStructure.ptrStructure;
94 if (!myImmediateWS.IsNull())
95 myImmediateWS->DrawStructure(astructure);
98 void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize)
100 if (!myImmediateWS.IsNull())
102 myImmediateWS->EndImmediatMode();
103 myImmediateWS.Nullify();
107 void OpenGl_GraphicDriver::EndPolyline ()
109 if (!myImmediateWS.IsNull())
110 myImmediateWS->EndPolyline();
113 void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
115 if (!myImmediateWS.IsNull())
116 myImmediateWS->Move(X,Y,Z);
119 void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
121 if (!myImmediateWS.IsNull())
122 myImmediateWS->SetLineColor(R,G,B);
125 void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type)
127 if (!myImmediateWS.IsNull())
128 myImmediateWS->SetLineType(Type);
131 void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
133 if (!myImmediateWS.IsNull())
134 myImmediateWS->SetLineWidth(Width);
137 void 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)
139 if (!myImmediateWS.IsNull())
140 myImmediateWS->SetMinMax(X1,Y1,Z1,X2,Y2,Z2);
143 void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
145 if (!myImmediateWS.IsNull())
146 myImmediateWS->Transform(AMatrix,AType);