| 1 | // File: OpenGl_View.hxx |
| 2 | // Created: 20 September 2011 |
| 3 | // Author: Sergey ZERCHANINOV |
| 4 | // Copyright: OPEN CASCADE 2011 |
| 5 | |
| 6 | #ifndef _OpenGl_View_Header |
| 7 | #define _OpenGl_View_Header |
| 8 | |
| 9 | #include <MMgt_TShared.hxx> |
| 10 | #include <Standard_DefineHandle.hxx> |
| 11 | |
| 12 | #include <TColStd_Array2OfReal.hxx> |
| 13 | #include <NCollection_List.hxx> |
| 14 | |
| 15 | #include <Quantity_NameOfColor.hxx> |
| 16 | #include <Aspect_FillMethod.hxx> |
| 17 | #include <Aspect_GradientFillMethod.hxx> |
| 18 | #include <Aspect_TypeOfTriedronPosition.hxx> |
| 19 | #include <Aspect_CLayer2d.hxx> |
| 20 | |
| 21 | #include <InterfaceGraphic_Graphic3d.hxx> |
| 22 | #include <InterfaceGraphic_Visual3d.hxx> |
| 23 | |
| 24 | #include <Graphic3d_CView.hxx> |
| 25 | #include <Graphic3d_CGraduatedTrihedron.hxx> |
| 26 | #include <Visual3d_TypeOfSurfaceDetail.hxx> |
| 27 | |
| 28 | #include <OpenGl_telem_view.hxx> |
| 29 | |
| 30 | #include <OpenGl_Light.hxx> |
| 31 | #include <OpenGl_PriorityList.hxx> |
| 32 | |
| 33 | #include <Handle_OpenGl_Trihedron.hxx> |
| 34 | #include <Handle_OpenGl_GraduatedTrihedron.hxx> |
| 35 | #include <Handle_OpenGl_Workspace.hxx> |
| 36 | #include <Handle_OpenGl_View.hxx> |
| 37 | |
| 38 | struct OPENGL_BG_TEXTURE |
| 39 | { |
| 40 | Tuint TexId; |
| 41 | Tint Width; |
| 42 | Tint Height; |
| 43 | Aspect_FillMethod Style; |
| 44 | }; |
| 45 | |
| 46 | struct OPENGL_BG_GRADIENT |
| 47 | { |
| 48 | TEL_COLOUR color1; |
| 49 | TEL_COLOUR color2; |
| 50 | Aspect_GradientFillMethod type; |
| 51 | }; |
| 52 | |
| 53 | struct OPENGL_EXTRA_REP |
| 54 | { |
| 55 | Tfloat vrp[3]; |
| 56 | Tfloat vpn[3]; |
| 57 | Tfloat vup[3]; |
| 58 | TEL_VIEW_MAPPING map; |
| 59 | Tfloat scaleFactors[3]; |
| 60 | }; |
| 61 | |
| 62 | struct OPENGL_CLIP_REP |
| 63 | { |
| 64 | Standard_Real equation[4]; |
| 65 | IMPLEMENT_MEMORY_OPERATORS |
| 66 | }; |
| 67 | |
| 68 | struct OPENGL_ZCLIP |
| 69 | { |
| 70 | struct { |
| 71 | Standard_Boolean IsOn; |
| 72 | Standard_ShortReal Limit; /* in the range [0., 1.] */ |
| 73 | } Back; |
| 74 | struct { |
| 75 | Standard_Boolean IsOn; |
| 76 | Standard_ShortReal Limit; /* in the range [0., 1.] */ |
| 77 | } Front; |
| 78 | }; |
| 79 | |
| 80 | struct OPENGL_FOG |
| 81 | { |
| 82 | Standard_Boolean IsOn; |
| 83 | Standard_ShortReal Front; /* in the range [0., 1.] */ |
| 84 | Standard_ShortReal Back; /* in the range [0., 1.] */ |
| 85 | TEL_COLOUR Color; |
| 86 | }; |
| 87 | |
| 88 | class OpenGl_Structure; |
| 89 | |
| 90 | class OpenGl_View : public MMgt_TShared |
| 91 | { |
| 92 | public: |
| 93 | OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext); |
| 94 | virtual ~OpenGl_View (); |
| 95 | |
| 96 | void SetTextureEnv (const Standard_Integer AId) { myTextureEnv = AId; } |
| 97 | void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; } |
| 98 | void SetBackfacing (const Standard_Integer AMode); |
| 99 | void SetLights (const CALL_DEF_VIEWCONTEXT &AContext); |
| 100 | void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; } |
| 101 | void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext); |
| 102 | void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext); |
| 103 | |
| 104 | void SetClipLimit (const CALL_DEF_VIEW &ACView); |
| 105 | void SetMapping (const CALL_DEF_VIEW &ACView); |
| 106 | void SetOrientation (const CALL_DEF_VIEW &ACView); |
| 107 | |
| 108 | void SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AFlag); |
| 109 | |
| 110 | void TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe); |
| 111 | void TriedronErase (); |
| 112 | |
| 113 | void GraduatedTrihedronDisplay (const Graphic3d_CGraduatedTrihedron &ACubic); |
| 114 | void GraduatedTrihedronErase (); |
| 115 | |
| 116 | Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h, |
| 117 | const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z, |
| 118 | Standard_ShortReal &xr, Standard_ShortReal &yr); |
| 119 | Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h, |
| 120 | const Standard_Integer xr, const Standard_Integer yr, |
| 121 | Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z); |
| 122 | Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h, |
| 123 | const Standard_Integer xr, const Standard_Integer yr, |
| 124 | Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z, |
| 125 | Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz); |
| 126 | void GetMatrices (TColStd_Array2OfReal& theMatOrient, |
| 127 | TColStd_Array2OfReal& theMatMapping, |
| 128 | const Standard_Boolean theIsCustom) const; |
| 129 | |
| 130 | Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); } |
| 131 | Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); } |
| 132 | |
| 133 | Standard_Integer Backfacing () const { return myBackfacing; } |
| 134 | |
| 135 | const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers ); |
| 136 | void EndTransformPersistence (); |
| 137 | |
| 138 | void DisplayStructure (const OpenGl_Structure *AStructure, const Standard_Integer APriority) { myStructures.Add(AStructure,APriority); } |
| 139 | void EraseStructure (const OpenGl_Structure *AStructure) { myStructures.Remove(AStructure); } |
| 140 | |
| 141 | void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle); |
| 142 | void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle); |
| 143 | void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType); |
| 144 | void SetBackgroundGradientType (const Aspect_GradientFillMethod AType); |
| 145 | |
| 146 | void Render (const Handle(OpenGl_Workspace) &AWorkspace, |
| 147 | const Graphic3d_CView& ACView, |
| 148 | const Aspect_CLayer2d& ACUnderLayer, |
| 149 | const Aspect_CLayer2d& ACOverLayer); |
| 150 | |
| 151 | // Type definition |
| 152 | // |
| 153 | DEFINE_STANDARD_RTTI(OpenGl_View) |
| 154 | |
| 155 | protected: |
| 156 | |
| 157 | void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace); |
| 158 | void RedrawLayer2d (const Handle(OpenGl_Workspace) &AWorkspace, const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer); |
| 159 | |
| 160 | Standard_Integer myTextureEnv; //WSTextureEnv |
| 161 | Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail |
| 162 | Standard_Integer myBackfacing; //WSBackfacing |
| 163 | |
| 164 | OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture |
| 165 | OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient |
| 166 | |
| 167 | //{ myViewRep |
| 168 | Tmatrix3 myOrientationMatrix; |
| 169 | Tmatrix3 myMappingMatrix; |
| 170 | |
| 171 | //Tint shield_indicator; |
| 172 | //TEL_COLOUR shield_colour; |
| 173 | //Tint border_indicator; |
| 174 | //TEL_COLOUR border_colour; |
| 175 | //Tint active_status; |
| 176 | |
| 177 | OPENGL_ZCLIP myZClip; |
| 178 | NCollection_List<OPENGL_CLIP_REP> myClippingPlanes; |
| 179 | |
| 180 | OPENGL_EXTRA_REP myExtra; |
| 181 | //} |
| 182 | |
| 183 | OPENGL_FOG myFog; |
| 184 | Handle(OpenGl_Trihedron) myTrihedron; |
| 185 | Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron; |
| 186 | |
| 187 | //View_LABViewContext |
| 188 | int myVisualization; |
| 189 | int myIntShadingMethod; |
| 190 | |
| 191 | //View_LABLight |
| 192 | OpenGl_ListOfLight myLights; |
| 193 | |
| 194 | //View_LABPlane |
| 195 | //View_LABAliasing |
| 196 | Standard_Boolean myAntiAliasing; |
| 197 | |
| 198 | //View_LABDepthCueing - fixed index used |
| 199 | |
| 200 | OpenGl_PriorityList myStructures; |
| 201 | |
| 202 | int myAnimationListIndex; |
| 203 | Standard_Boolean myAnimationListReady; |
| 204 | |
| 205 | const TEL_TRANSFORM_PERSISTENCE *myTransPers; |
| 206 | Standard_Boolean myIsTransPers; |
| 207 | |
| 208 | Standard_Boolean myResetFLIST; |
| 209 | |
| 210 | public: |
| 211 | IMPLEMENT_MEMORY_OPERATORS |
| 212 | }; |
| 213 | |
| 214 | #endif //_OpenGl_View_Header |