| 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 | |
| 21 | #ifndef _OpenGl_View_Header |
| 22 | #define _OpenGl_View_Header |
| 23 | |
| 24 | #include <MMgt_TShared.hxx> |
| 25 | #include <Standard_DefineHandle.hxx> |
| 26 | |
| 27 | #include <TColStd_Array2OfReal.hxx> |
| 28 | #include <NCollection_List.hxx> |
| 29 | |
| 30 | #include <Quantity_NameOfColor.hxx> |
| 31 | #include <Aspect_FillMethod.hxx> |
| 32 | #include <Aspect_GradientFillMethod.hxx> |
| 33 | #include <Aspect_TypeOfTriedronPosition.hxx> |
| 34 | #include <Aspect_CLayer2d.hxx> |
| 35 | |
| 36 | #include <InterfaceGraphic_Graphic3d.hxx> |
| 37 | #include <InterfaceGraphic_Visual3d.hxx> |
| 38 | |
| 39 | #include <Graphic3d_CView.hxx> |
| 40 | #include <Graphic3d_CGraduatedTrihedron.hxx> |
| 41 | #include <Visual3d_TypeOfSurfaceDetail.hxx> |
| 42 | |
| 43 | #include <OpenGl_telem_view.hxx> |
| 44 | #include <OpenGl_LayerList.hxx> |
| 45 | #include <OpenGl_Light.hxx> |
| 46 | |
| 47 | #include <Handle_OpenGl_Trihedron.hxx> |
| 48 | #include <Handle_OpenGl_GraduatedTrihedron.hxx> |
| 49 | #include <Handle_OpenGl_Workspace.hxx> |
| 50 | #include <Handle_OpenGl_View.hxx> |
| 51 | |
| 52 | struct OPENGL_BG_TEXTURE |
| 53 | { |
| 54 | Tuint TexId; |
| 55 | Tint Width; |
| 56 | Tint Height; |
| 57 | Aspect_FillMethod Style; |
| 58 | }; |
| 59 | |
| 60 | struct OPENGL_BG_GRADIENT |
| 61 | { |
| 62 | TEL_COLOUR color1; |
| 63 | TEL_COLOUR color2; |
| 64 | Aspect_GradientFillMethod type; |
| 65 | }; |
| 66 | |
| 67 | struct OPENGL_EXTRA_REP |
| 68 | { |
| 69 | Tfloat vrp[3]; |
| 70 | Tfloat vpn[3]; |
| 71 | Tfloat vup[3]; |
| 72 | TEL_VIEW_MAPPING map; |
| 73 | Tfloat scaleFactors[3]; |
| 74 | }; |
| 75 | |
| 76 | struct OPENGL_CLIP_REP |
| 77 | { |
| 78 | Standard_Real equation[4]; |
| 79 | DEFINE_STANDARD_ALLOC |
| 80 | }; |
| 81 | |
| 82 | struct OPENGL_ZCLIP |
| 83 | { |
| 84 | struct { |
| 85 | Standard_Boolean IsOn; |
| 86 | Standard_ShortReal Limit; /* in the range [0., 1.] */ |
| 87 | } Back; |
| 88 | struct { |
| 89 | Standard_Boolean IsOn; |
| 90 | Standard_ShortReal Limit; /* in the range [0., 1.] */ |
| 91 | } Front; |
| 92 | }; |
| 93 | |
| 94 | struct OPENGL_FOG |
| 95 | { |
| 96 | Standard_Boolean IsOn; |
| 97 | Standard_ShortReal Front; /* in the range [0., 1.] */ |
| 98 | Standard_ShortReal Back; /* in the range [0., 1.] */ |
| 99 | TEL_COLOUR Color; |
| 100 | }; |
| 101 | |
| 102 | class OpenGl_Structure; |
| 103 | |
| 104 | class OpenGl_View : public MMgt_TShared |
| 105 | { |
| 106 | public: |
| 107 | OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext); |
| 108 | virtual ~OpenGl_View (); |
| 109 | |
| 110 | void SetTextureEnv (const Standard_Integer AId) { myTextureEnv = AId; } |
| 111 | void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; } |
| 112 | void SetBackfacing (const Standard_Integer AMode); |
| 113 | void SetLights (const CALL_DEF_VIEWCONTEXT &AContext); |
| 114 | void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; } |
| 115 | void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext); |
| 116 | void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext); |
| 117 | |
| 118 | void SetClipLimit (const CALL_DEF_VIEW &ACView); |
| 119 | void SetMapping (const CALL_DEF_VIEW &ACView); |
| 120 | void SetOrientation (const CALL_DEF_VIEW &ACView); |
| 121 | |
| 122 | void SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AFlag); |
| 123 | |
| 124 | void TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe); |
| 125 | void TriedronErase (); |
| 126 | |
| 127 | void GraduatedTrihedronDisplay (const Graphic3d_CGraduatedTrihedron &ACubic); |
| 128 | void GraduatedTrihedronErase (); |
| 129 | |
| 130 | Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h, |
| 131 | const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z, |
| 132 | Standard_ShortReal &xr, Standard_ShortReal &yr); |
| 133 | Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h, |
| 134 | const Standard_Integer xr, const Standard_Integer yr, |
| 135 | Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z); |
| 136 | Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h, |
| 137 | const Standard_Integer xr, const Standard_Integer yr, |
| 138 | Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z, |
| 139 | Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz); |
| 140 | void GetMatrices (TColStd_Array2OfReal& theMatOrient, |
| 141 | TColStd_Array2OfReal& theMatMapping, |
| 142 | const Standard_Boolean theIsCustom) const; |
| 143 | |
| 144 | Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); } |
| 145 | Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); } |
| 146 | |
| 147 | Standard_Integer Backfacing () const { return myBackfacing; } |
| 148 | |
| 149 | const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers ); |
| 150 | void EndTransformPersistence (); |
| 151 | |
| 152 | //! Add structure to display list with specified priority. |
| 153 | //! The structure will be added to associated with it z layer. |
| 154 | //! If the z layer is not presented in the view, the structure will |
| 155 | //! be displayed in default bottom-level z layer. |
| 156 | void DisplayStructure (const OpenGl_Structure *theStructure, |
| 157 | const Standard_Integer thePriority); |
| 158 | |
| 159 | //! Erase structure from display list. |
| 160 | void EraseStructure (const OpenGl_Structure *theStructure); |
| 161 | |
| 162 | //! Insert a new top-level z layer with ID <theLayerId> |
| 163 | void AddZLayer (const Standard_Integer theLayerId); |
| 164 | |
| 165 | //! Remove a z layer with ID <theLayerId> |
| 166 | void RemoveZLayer (const Standard_Integer theLayerId); |
| 167 | |
| 168 | //! Display structure in z layer with ID <theNewLayerId> |
| 169 | //! If the layer with ID <theNewLayerId> is not presented in the view, |
| 170 | //! the structure will be displayed in default bottom-level layer. |
| 171 | void ChangeZLayer (const OpenGl_Structure *theStructure, |
| 172 | const Standard_Integer theNewLayerId); |
| 173 | |
| 174 | void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle); |
| 175 | void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle); |
| 176 | void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType); |
| 177 | void SetBackgroundGradientType (const Aspect_GradientFillMethod AType); |
| 178 | |
| 179 | void Render (const Handle(OpenGl_Workspace) &AWorkspace, |
| 180 | const Graphic3d_CView& ACView, |
| 181 | const Aspect_CLayer2d& ACUnderLayer, |
| 182 | const Aspect_CLayer2d& ACOverLayer); |
| 183 | |
| 184 | // Type definition |
| 185 | // |
| 186 | DEFINE_STANDARD_RTTI(OpenGl_View) |
| 187 | |
| 188 | protected: |
| 189 | |
| 190 | void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace); |
| 191 | void RedrawLayer2d (const Handle(OpenGl_Workspace) &AWorkspace, const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer); |
| 192 | |
| 193 | Standard_Integer myTextureEnv; //WSTextureEnv |
| 194 | Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail |
| 195 | Standard_Integer myBackfacing; //WSBackfacing |
| 196 | |
| 197 | OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture |
| 198 | OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient |
| 199 | |
| 200 | //{ myViewRep |
| 201 | Tmatrix3 myOrientationMatrix; |
| 202 | Tmatrix3 myMappingMatrix; |
| 203 | |
| 204 | //Tint shield_indicator; |
| 205 | //TEL_COLOUR shield_colour; |
| 206 | //Tint border_indicator; |
| 207 | //TEL_COLOUR border_colour; |
| 208 | //Tint active_status; |
| 209 | |
| 210 | OPENGL_ZCLIP myZClip; |
| 211 | NCollection_List<OPENGL_CLIP_REP> myClippingPlanes; |
| 212 | |
| 213 | OPENGL_EXTRA_REP myExtra; |
| 214 | //} |
| 215 | |
| 216 | OPENGL_FOG myFog; |
| 217 | Handle(OpenGl_Trihedron) myTrihedron; |
| 218 | Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron; |
| 219 | |
| 220 | //View_LABViewContext |
| 221 | int myVisualization; |
| 222 | int myIntShadingMethod; |
| 223 | |
| 224 | //View_LABLight |
| 225 | OpenGl_ListOfLight myLights; |
| 226 | |
| 227 | //View_LABPlane |
| 228 | //View_LABAliasing |
| 229 | Standard_Boolean myAntiAliasing; |
| 230 | |
| 231 | //View_LABDepthCueing - fixed index used |
| 232 | |
| 233 | OpenGl_LayerList myZLayers; |
| 234 | |
| 235 | int myAnimationListIndex; |
| 236 | Standard_Boolean myAnimationListReady; |
| 237 | |
| 238 | const TEL_TRANSFORM_PERSISTENCE *myTransPers; |
| 239 | Standard_Boolean myIsTransPers; |
| 240 | |
| 241 | Standard_Boolean myResetFLIST; |
| 242 | |
| 243 | public: |
| 244 | DEFINE_STANDARD_ALLOC |
| 245 | }; |
| 246 | |
| 247 | #endif //_OpenGl_View_Header |