1 // Created on: 2011-09-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.
20 #ifndef _OpenGl_Display_Header
21 #define _OpenGl_Display_Header
23 #include <Handle_OpenGl_Display.hxx>
24 #include <MMgt_TShared.hxx>
26 #include <Standard_CString.hxx>
27 #include <TColStd_HArray1OfByte.hxx>
28 #include <NCollection_DataMap.hxx>
30 #include <Aspect_Display.hxx>
31 #include <Aspect_Drawable.hxx>
32 #include <Aspect_TypeOfLine.hxx>
33 #include <Aspect_TypeOfMarker.hxx>
35 #include <Font_FontAspect.hxx>
37 #include <InterfaceGraphic_telem.hxx>
39 #include <Handle_OpenGl_Window.hxx>
41 struct OpenGl_Facilities
51 struct OPENGL_MARKER_DATA
60 typedef NCollection_DataMap<int,OPENGL_MARKER_DATA> OpenGl_MapOfUserMarker;
62 class OpenGl_AspectText;
63 struct OpenGl_TextParam;
65 class OpenGl_Display : public MMgt_TShared
68 OpenGl_Display (const Standard_CString ADisplay);
69 OpenGl_Display (const Aspect_Display ADisplay);
70 virtual ~OpenGl_Display ();
72 Aspect_Display GetDisplay () const { return myDisplay; }
74 Handle(OpenGl_Window) GetWindow (const Aspect_Drawable AParent) const;
75 void SetWindow (const Aspect_Drawable AParent, const Handle(OpenGl_Window) &AWindow);
77 const OpenGl_Facilities & Facilities () const { return myFacilities; }
79 Standard_Boolean DBuffer () const { return myDBuffer; }
80 Standard_Boolean Dither () const { return myDither; }
81 Standard_Boolean BackDither () const { return myBackDither; }
82 Standard_Boolean Walkthrough () const { return myWalkthrough; }
83 Standard_Boolean SymPerspective() const { return mySymPerspective; }
84 Standard_Boolean PolygonOffset (Standard_ShortReal &AFactor, Standard_ShortReal &AUnits) const
86 AFactor = myOffsetFactor;
87 AUnits = myOffsetUnits;
90 Standard_Integer AntiAliasingMode () const { return myAntiAliasingMode; }
94 void InitAttributes ();
96 const char * GetStringForMarker (const Aspect_TypeOfMarker AType, const Tfloat AVal) const;
98 void SetBaseForMarker () const;
100 void SetTypeOfLine (const Aspect_TypeOfLine AType) const;
102 void SetTypeOfHatch (const int AType) const;
106 void AddUserMarker (const Standard_Integer AIndex,
107 const Standard_Integer AMarkWidth,
108 const Standard_Integer AMarkHeight,
109 const Handle(TColStd_HArray1OfByte)& ATexture);
111 void UpdateUserMarkers ();
113 Standard_Integer GetUserMarkerListIndex (const Standard_Integer AIndex) const;
115 friend class OpenGl_Window;
119 DEFINE_STANDARD_RTTI(OpenGl_Display)
125 void ExportText (const wchar_t *text, const int is2d, const float x, const float y, const float z, const OpenGl_AspectText *aspect, const OpenGl_TextParam *param, const short height);
128 static void getGL2PSFontName(const char *src_font, char *ps_font);
131 Aspect_Display myDisplay;
132 OpenGl_Facilities myFacilities;
134 Standard_Boolean myDBuffer;
135 Standard_Boolean myDither;
136 Standard_Boolean myBackDither;
137 Standard_Boolean myWalkthrough;
138 Standard_Boolean mySymPerspective;
139 Standard_ShortReal myOffsetFactor;
140 Standard_ShortReal myOffsetUnits;
141 Standard_Integer myAntiAliasingMode;
143 #if (defined(_WIN32) || defined(__WIN32__))
144 NCollection_DataMap<Aspect_Drawable, Handle(OpenGl_Window)> myMapOfWindows;
146 NCollection_DataMap<Standard_Integer, Handle(OpenGl_Window)> myMapOfWindows;
149 unsigned int myLinestyleBase;
150 unsigned int myPatternBase;
151 unsigned int myMarkerBase;
153 OpenGl_MapOfUserMarker myMapOfUM;
156 DEFINE_STANDARD_ALLOC
159 extern Handle(OpenGl_Display) openglDisplay;
161 #endif //OpenGl_Workspace_Header