0027787: Visualization, TKOpenGl - Optimize rendering by additional check whether...
[occt.git] / src / OpenGl / OpenGl_Trihedron.hxx
1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2013 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #ifndef _OpenGl_Trihedron_Header
17 #define _OpenGl_Trihedron_Header
18
19 #include <OpenGl_Element.hxx>
20
21 #include <Aspect_TypeOfTriedronPosition.hxx>
22 #include <OpenGl_AspectLine.hxx>
23 #include <OpenGl_AspectText.hxx>
24 #include <OpenGl_Cylinder.hxx>
25 #include <OpenGl_Disk.hxx>
26 #include <OpenGl_Sphere.hxx>
27 #include <OpenGl_Text.hxx>
28 #include <Quantity_NameOfColor.hxx>
29
30 //! Class render trihedron
31 class OpenGl_Trihedron : public OpenGl_Element
32 {
33 public:
34
35   //! Default constructor.
36   OpenGl_Trihedron();
37
38   //! Destructor.
39   virtual ~OpenGl_Trihedron();
40
41   //! Render the element.
42   virtual void Render (const Handle(OpenGl_Workspace)& theWorkspace) const;
43
44   //! Release OpenGL resources.
45   virtual void Release (OpenGl_Context* theCtx);
46
47 public:
48
49   //! Switch wireframe / shaded trihedron.
50   void SetWireframe (const Standard_Boolean theAsWireframe) { myIsWireframe = theAsWireframe; }
51
52   //! Setup the corner to draw the trihedron.
53   void SetPosition (const Aspect_TypeOfTriedronPosition thePosition) { myPos = thePosition; }
54
55   //! Setup the scale factor.
56   void SetScale (const Standard_Real theScale);
57
58   //! Setup the size ratio factor.
59   void SetSizeRatio (const Standard_Real theRatio);
60
61   //! Setup the arrow diameter.
62   void SetArrowDiameter (const Standard_Real theDiam);
63
64   //! Setup the number of facets for tessellation.
65   void SetNbFacets (const Standard_Integer theNbFacets);
66
67   //! Setup color of text labels.
68   void SetLabelsColor (const Quantity_Color& theColor);
69
70   //! Setup per-arrow color.
71   void SetArrowsColors (const Quantity_Color& theColorX,
72                         const Quantity_Color& theColorY,
73                         const Quantity_Color& theColorZ);
74
75 protected:
76
77   //! Invalidate Primitive Arrays.
78   void invalidate();
79
80   void redraw(const Handle(OpenGl_Workspace)& theWorkspace) const;
81   void redrawZBuffer(const Handle(OpenGl_Workspace)& theWorkspace) const;
82
83   //! Resets current model-view and projection transformations and sets
84   //! translation for trihedron position
85   //! @sa Aspect_TypeOfTriedronPosition
86   void resetTransformations (const Handle(OpenGl_Workspace)& theWorkspace) const;
87
88 protected:
89
90   Aspect_TypeOfTriedronPosition myPos;
91   Standard_Real myScale;
92   Standard_Boolean myIsWireframe;
93   OpenGl_Vec4 myXColor;
94   OpenGl_Vec4 myYColor;
95   OpenGl_Vec4 myZColor;
96   float myRatio;
97   float myDiameter;
98   int   myNbFacettes;
99
100   OpenGl_AspectLine              myAspectLine;
101   OpenGl_AspectText              myAspectText;
102   mutable OpenGl_Text            myLabelX;
103   mutable OpenGl_Text            myLabelY;
104   mutable OpenGl_Text            myLabelZ;
105   mutable OpenGl_Cylinder        myCylinder;
106   mutable OpenGl_Sphere          mySphere;
107   mutable OpenGl_Cylinder        myCone;
108   mutable OpenGl_Disk            myDisk;
109   mutable OpenGl_PrimitiveArray  myLine;
110   mutable OpenGl_PrimitiveArray  myCircle;
111
112 public:
113
114   DEFINE_STANDARD_ALLOC
115
116 };
117
118 #endif //_OpenGl_Trihedron_Header