0024847: CLang warnings -Wdeprecated-writable-strings in OpenGl_Display
[occt.git] / src / OpenGl / OpenGl_View.hxx
index 9598f65..b1cbe18 100644 (file)
@@ -1,21 +1,17 @@
 // Created on: 2011-09-20
 // Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
+// Copyright (c) 2011-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #ifndef _OpenGl_View_Header
 #define _OpenGl_View_Header
 
 #include <Graphic3d_CView.hxx>
 #include <Graphic3d_CGraduatedTrihedron.hxx>
+#include <Graphic3d_SequenceOfHClipPlane.hxx>
+#include <Graphic3d_ZLayerSettings.hxx>
 #include <Visual3d_TypeOfSurfaceDetail.hxx>
 
-#include <OpenGl_telem_view.hxx>
 #include <OpenGl_LayerList.hxx>
 #include <OpenGl_Light.hxx>
+#include <OpenGl_LineAttributes.hxx>
 
 #include <Handle_OpenGl_Context.hxx>
+#include <Handle_OpenGl_GraphicDriver.hxx>
 #include <Handle_OpenGl_Workspace.hxx>
 #include <Handle_OpenGl_View.hxx>
 #include <Handle_OpenGl_Texture.hxx>
@@ -63,21 +62,6 @@ struct OPENGL_BG_GRADIENT
   Aspect_GradientFillMethod type;
 };
 
-struct OPENGL_EXTRA_REP
-{
-  Tfloat  vrp[3];
-  Tfloat  vpn[3];
-  Tfloat  vup[3];
-  TEL_VIEW_MAPPING map;
-  Tfloat  scaleFactors[3];
-};
-
-struct OPENGL_CLIP_REP
-{
-  Standard_Real equation[4];
-  DEFINE_STANDARD_ALLOC
-};
-
 struct OPENGL_ZCLIP
 {
   struct {
@@ -98,31 +82,33 @@ struct OPENGL_FOG
   TEL_COLOUR         Color;
 };
 
+struct OpenGl_Matrix;
 class OpenGl_GraduatedTrihedron;
 class OpenGl_Structure;
 class OpenGl_Trihedron;
 class Handle(OpenGl_PrinterContext);
+class OpenGl_StateCounter;
 
 class OpenGl_View : public MMgt_TShared
 {
  public:
-  OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext);
+  OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext, OpenGl_StateCounter* theCounter);
   virtual ~OpenGl_View ();
 
   void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
 
   void SetTextureEnv (const Handle(OpenGl_Context)&       theCtx,
                       const Handle(Graphic3d_TextureEnv)& theTexture);
-  void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; }
+  void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode);
   void SetBackfacing (const Standard_Integer AMode);
   void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
   void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
-  void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext);
+  void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
   void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
 
+  void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
+
   void SetClipLimit (const Graphic3d_CView& theCView);
-  void SetMapping (const Graphic3d_CView& theCView);
-  void SetOrientation (const Graphic3d_CView& theCView);
 
   void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
 
@@ -137,37 +123,30 @@ class OpenGl_View : public MMgt_TShared
                                   const Graphic3d_CGraduatedTrihedron& theCubic);
   void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
 
-  Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
-                                          const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
-                                          Standard_ShortReal &xr, Standard_ShortReal &yr);
-  Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
-                                          const Standard_Integer xr, const Standard_Integer yr,
-                                          Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
-  Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
-                                                 const Standard_Integer xr, const Standard_Integer yr,
-                                                 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
-                                                 Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
-  void GetMatrices (TColStd_Array2OfReal&  theMatOrient,
-                    TColStd_Array2OfReal&  theMatMapping,
-                    const Standard_Boolean theIsCustom) const;
-
-  Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
-  Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
+  Standard_Real Height () const { return myCamera->ViewDimensions().X(); }
+  Standard_Real Width () const { return myCamera->ViewDimensions().Y(); }
 
   Standard_Integer Backfacing () const { return myBackfacing; }
 
-  const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
-  void EndTransformPersistence ();
+  const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
+                                                               const TEL_TRANSFORM_PERSISTENCE *theTransPers);
+  void EndTransformPersistence (const Handle(OpenGl_Context)& theCtx);
 
   //! Add structure to display list with specified priority.
   //! The structure will be added to associated with it z layer.
   //! If the z layer is not presented in the view, the structure will
   //! be displayed in default bottom-level z layer.
-  void DisplayStructure (const OpenGl_Structure *theStructure,
+  void DisplayStructure (const OpenGl_StructuretheStructure,
                          const Standard_Integer  thePriority);
 
   //! Erase structure from display list.
-  void EraseStructure (const OpenGl_Structure *theStructure);
+  void EraseStructure (const OpenGl_Structure* theStructure);
+
+  //! Add structure to the list of immediate structures.
+  void DisplayImmediateStructure (const OpenGl_Structure* theStructure);
+
+  //! Erase structure from display list.
+  void EraseImmediateStructure (const OpenGl_Structure* theStructure);
 
   //! Insert a new top-level z layer with ID <theLayerId>
   void AddZLayer (const Standard_Integer theLayerId);
@@ -181,6 +160,10 @@ class OpenGl_View : public MMgt_TShared
   void ChangeZLayer (const OpenGl_Structure *theStructure,
                      const Standard_Integer  theNewLayerId);
 
+  //! Sets the settings for a single Z layer of specified view.
+  void SetZLayerSettings (const Standard_Integer theLayerId,
+                          const Graphic3d_ZLayerSettings theSettings);
+
   void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
   void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
   void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
@@ -192,40 +175,67 @@ class OpenGl_View : public MMgt_TShared
                const Aspect_CLayer2d&               theCUnderLayer,
                const Aspect_CLayer2d&               theCOverLayer);
 
-public:
 
-  DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
+  void DrawBackground (OpenGl_Workspace& theWorkspace);
+
+  //! Returns list of OpenGL Z-layers.
+  const OpenGl_LayerList& LayerList() const { return myZLayers; }
+
+  //! Returns list of openGL light sources.
+  const OpenGl_ListOfLight& LightList() const { return myLights; }
+
+  //! Returns OpenGL environment map.
+  const Handle(OpenGl_Texture)& TextureEnv() const { return myTextureEnv; }
 
- protected:
+  //! Returns visualization mode for objects in the view.
+  Visual3d_TypeOfSurfaceDetail SurfaceDetail() const { return mySurfaceDetail; }
+
+  void GetMatrices (TColStd_Array2OfReal&  theMatOrient,
+                    TColStd_Array2OfReal&  theMatMapping) const;
+
+  //! Returns list of immediate structures rendered on top of main presentation
+  const OpenGl_SequenceOfStructure& ImmediateStructures() const
+  {
+    return myImmediateList;
+  }
+
+  //! Returns modification state for ray-tracing.
+  Standard_Size ModificationState() const { return myModificationState; }
+
+protected:
 
   void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
   void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext,
-                      const Handle(OpenGl_Workspace)&      theWorkspace,
                       const Graphic3d_CView&               theCView,
                       const Aspect_CLayer2d&               theCLayer);
 
-  Handle(OpenGl_Texture) myTextureEnv;
-  Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
-  Standard_Integer myBackfacing; //WSBackfacing
-
-  OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
-  OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
-
-  //{ myViewRep
-  Tmatrix3    myOrientationMatrix;
-  Tmatrix3    myMappingMatrix;
-
-  //Tint        shield_indicator;
-  //TEL_COLOUR  shield_colour;
-  //Tint        border_indicator;
-  //TEL_COLOUR  border_colour;
-  //Tint        active_status;
+  //! Redraw contents of model scene: clipping planes,
+  //! lights, structures. The peculiar properties of "scene" is that
+  //! it requires empty Z-Buffer and uses projection and orientation
+  //! matrices supplied by 3d view.
+  //! @param thePrintCtx [in] printer context which facilitates tiled printing.
+  //! @param theWorkspace [in] rendering workspace.
+  //! @param theCView [in] view data.
+  //! @param theProjection [in] view projection matrix.
+  //! @param theOrientation [in] view orientation matrix.
+  void RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintContext,
+                    const Handle(OpenGl_Workspace)& theWorkspace,
+                    const OpenGl_Matrix* theProjection,
+                    const OpenGl_Matrix* theOrientation);
+
+  Handle(OpenGl_LineAttributes) myLineAttribs;
+  Handle(OpenGl_Texture)        myTextureEnv;
+  Visual3d_TypeOfSurfaceDetail  mySurfaceDetail;
+  Standard_Integer              myBackfacing;
+
+  OPENGL_BG_TEXTURE  myBgTexture;
+  OPENGL_BG_GRADIENT myBgGradient;
 
   OPENGL_ZCLIP   myZClip;
-  NCollection_List<OPENGL_CLIP_REP> myClippingPlanes;
 
-  OPENGL_EXTRA_REP myExtra;
-  //}
+  Graphic3d_SequenceOfHClipPlane myClipPlanes;
+  
+  Handle(Graphic3d_Camera) myCamera;
 
   OPENGL_FOG myFog;
   OpenGl_Trihedron*          myTrihedron;
@@ -244,13 +254,32 @@ public:
 
   //View_LABDepthCueing - fixed index used
 
-  OpenGl_LayerList myZLayers;
+  OpenGl_LayerList           myZLayers;       //!< main list of displayed structure, sorted by layers
+  OpenGl_SequenceOfStructure myImmediateList; //!< list of immediate structures rendered on top of main presentation
 
   const TEL_TRANSFORM_PERSISTENCE *myTransPers;
   Standard_Boolean myIsTransPers;
 
- public:
+  //! Modification state
+  Standard_Size myProjectionState;
+  Standard_Size myModelViewState;
+  OpenGl_StateCounter* myStateCounter;
+
+  Standard_Size myCurrLightSourceState;
+
+  typedef std::pair<Standard_Size, Standard_Size> StateInfo;
+
+  StateInfo myLastOrientationState;
+  StateInfo myLastViewMappingState;
+  StateInfo myLastLightSourceState;
+
+  Standard_Size myModificationState;
+
+public:
+
   DEFINE_STANDARD_ALLOC
+  DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
+
 };
 
-#endif //_OpenGl_View_Header
+#endif // _OpenGl_View_Header