0024005: Intersecting a slightly off angle plane with a cylinder takes 7+ seconds
[occt.git] / src / OpenGl / OpenGl_Display.hxx
1 // Created on: 2011-09-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
20 #ifndef _OpenGl_Display_Header
21 #define _OpenGl_Display_Header
22
23 #include <Handle_OpenGl_Display.hxx>
24 #include <MMgt_TShared.hxx>
25
26 #include <Standard_CString.hxx>
27 #include <TColStd_HArray1OfByte.hxx>
28 #include <NCollection_DataMap.hxx>
29
30 #include <Aspect_Display.hxx>
31 #include <Aspect_DisplayConnection.hxx>
32 #include <Aspect_Drawable.hxx>
33 #include <Aspect_TypeOfLine.hxx>
34 #include <Aspect_TypeOfMarker.hxx>
35
36 #include <Font_FontAspect.hxx>
37
38 #include <InterfaceGraphic_telem.hxx>
39
40 #include <Handle_OpenGl_Window.hxx>
41
42 struct OpenGl_Facilities
43 {
44   int AntiAliasing;
45   int DepthCueing;
46   int DoubleBuffer;
47   int ZBuffer;
48   int MaxLights;
49   int MaxViews;
50 };
51
52 class OpenGl_AspectText;
53 struct OpenGl_TextParam;
54
55 class OpenGl_Display : public MMgt_TShared
56 {
57  public:
58   OpenGl_Display (const Handle(Aspect_DisplayConnection)& theDisplayConnection);
59   virtual ~OpenGl_Display ();
60
61   Aspect_Display GetDisplay () const { return myDisplay; }
62
63   Handle(OpenGl_Window) GetWindow (const Aspect_Drawable AParent) const;
64   void SetWindow (const Aspect_Drawable AParent, const Handle(OpenGl_Window) &AWindow);
65
66   const OpenGl_Facilities & Facilities () const { return myFacilities; }
67
68   Standard_Boolean DBuffer () const { return myDBuffer; }
69   Standard_Boolean Dither () const { return myDither; }
70   Standard_Boolean BackDither () const { return myBackDither; }
71   Standard_Boolean Walkthrough () const { return myWalkthrough; }
72   Standard_Boolean SymPerspective() const { return mySymPerspective; }
73   Standard_Boolean PolygonOffset (Standard_ShortReal &AFactor, Standard_ShortReal &AUnits) const
74   {
75     AFactor = myOffsetFactor;
76     AUnits = myOffsetUnits;
77     return Standard_True;
78   }
79   Standard_Integer AntiAliasingMode () const { return myAntiAliasingMode; }
80
81   // System attributes
82
83   void InitAttributes ();
84
85   void SetTypeOfLine (const Aspect_TypeOfLine AType) const;
86
87   void SetTypeOfHatch (const int AType) const;
88
89   friend class OpenGl_Window;
90
91   // Type definition
92   //
93   DEFINE_STANDARD_RTTI(OpenGl_Display)
94
95  protected:
96
97   void Init ();
98
99   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);
100
101 #ifdef HAVE_GL2PS
102   static void getGL2PSFontName(const char *src_font, char *ps_font);
103 #endif
104
105   Aspect_Display   myDisplay;
106   OpenGl_Facilities myFacilities;
107
108   Standard_Boolean myDBuffer;
109   Standard_Boolean myDither;
110   Standard_Boolean myBackDither;
111   Standard_Boolean myWalkthrough;
112   Standard_Boolean mySymPerspective;
113   Standard_ShortReal myOffsetFactor;
114   Standard_ShortReal myOffsetUnits;
115   Standard_Integer myAntiAliasingMode;
116
117 #if (defined(_WIN32) || defined(__WIN32__))
118   NCollection_DataMap<Aspect_Drawable,  Handle(OpenGl_Window)> myMapOfWindows;
119 #else
120   NCollection_DataMap<Standard_Integer, Handle(OpenGl_Window)> myMapOfWindows;
121 #endif
122
123   unsigned int myLinestyleBase;
124   unsigned int myPatternBase;
125
126  public:
127   DEFINE_STANDARD_ALLOC
128 };
129
130 extern Handle(OpenGl_Display) openglDisplay;
131
132 #endif //OpenGl_Workspace_Header