Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-30 10:30:03

0001 // Created on: 1998-07-16
0002 // Created by: CAL
0003 // Copyright (c) 1998-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _V3d_RectangularGrid_HeaderFile
0018 #define _V3d_RectangularGrid_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Aspect_RectangularGrid.hxx>
0023 #include <V3d_ViewerPointer.hxx>
0024 #include <gp_Ax3.hxx>
0025 class Graphic3d_Structure;
0026 class Graphic3d_Group;
0027 
0028 //! @deprecated Kept for backward compatibility. CPU-generated grid bound to a V3d_Viewer.
0029 //! New code should drive grids through V3d_View::GridDisplay(Aspect_GridParams, gp_Ax3),
0030 //! which renders an AA, shader-based grid and supports unbounded extents, background mode, arc
0031 //! ranges and per-axis scales. This class consumes the same Aspect_RectangularGrid
0032 //! parameters where the CPU path can render them; unsupported parameters are reported
0033 //! via Message::SendWarning() and ignored.
0034 class V3d_RectangularGrid : public Aspect_RectangularGrid
0035 {
0036   DEFINE_STANDARD_RTTIEXT(V3d_RectangularGrid, Aspect_RectangularGrid)
0037 public:
0038   //! Constructor. Builds a CPU-rendered rectangular grid bound to @p aViewer.
0039   //! Default size is 0.5 * Viewer->DefaultViewSize() on each axis (bounded);
0040   //! ZOffset defaults to step / 50.
0041   //! @deprecated Prefer V3d_View::GridDisplay with Aspect_GridParams for shader-based grids.
0042   //! @param[in] aViewer     viewer that owns the grid (and provides DefaultViewSize)
0043   //! @param[in] aColor      color of the regular grid lines / points
0044   //! @param[in] aTenthColor color of every 10-th line (axis emphasis)
0045   Standard_EXPORT V3d_RectangularGrid(const V3d_ViewerPointer& aViewer,
0046                                       const Quantity_Color&    aColor,
0047                                       const Quantity_Color&    aTenthColor);
0048 
0049   Standard_EXPORT ~V3d_RectangularGrid() override;
0050 
0051   //! Updates the grid colors and triggers a re-display when they actually change.
0052   //! @param[in] aColor      color of the regular lines / points
0053   //! @param[in] aTenthColor color of every 10-th line
0054   Standard_EXPORT void SetColors(const Quantity_Color& aColor,
0055                                  const Quantity_Color& aTenthColor) override;
0056 
0057   //! Display the CPU grid in the owning viewer's structure manager.
0058   Standard_EXPORT void Display() override;
0059 
0060   //! Erase the CPU grid (the underlying Graphic3d_Structure is hidden, not destroyed).
0061   Standard_EXPORT void Erase() const override;
0062 
0063   //! Returns true if the grid structure is currently displayed.
0064   Standard_EXPORT bool IsDisplayed() const override;
0065 
0066   //! Returns the grid bounds and Z offset (alias for SizeX/SizeY/ZOffset).
0067   //! @param[out] XSize  width  along grid X
0068   //! @param[out] YSize  height along grid Y
0069   //! @param[out] OffSet plane-normal displacement of the rendered grid
0070   Standard_EXPORT void GraphicValues(double& XSize, double& YSize, double& OffSet) const;
0071 
0072   //! Sets the grid bounds and Z offset (alias for SetSizeX/SetSizeY/SetZOffset).
0073   //! @param[in] XSize  width  along grid X
0074   //! @param[in] YSize  height along grid Y
0075   //! @param[in] OffSet plane-normal displacement
0076   Standard_EXPORT void SetGraphicValues(const double XSize,
0077                                         const double YSize,
0078                                         const double OffSet);
0079 
0080   //! Dumps the content of me into the stream.
0081   //! @param[in,out] theOStream destination stream
0082   //! @param[in]     theDepth   recursion depth (-1 for full)
0083   Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const override;
0084 
0085 protected:
0086   //! Recomputes the structure transformation and the line / point primitive arrays
0087   //! whenever a parameter or the privileged plane changes.
0088   Standard_EXPORT void UpdateDisplay() override;
0089 
0090 private:
0091   Standard_EXPORT void DefineLines();
0092 
0093   Standard_EXPORT void DefinePoints();
0094 
0095 private:
0096   //! Custom Graphic3d_Structure implementation.
0097   class RectangularGridStructure;
0098 
0099 private:
0100   occ::handle<Graphic3d_Structure> myStructure;
0101   occ::handle<Graphic3d_Group>     myGroup;
0102   gp_Ax3                           myCurViewPlane;
0103   V3d_ViewerPointer                myViewer;
0104   bool                             myCurAreDefined;
0105   bool                             myToComputePrs;
0106   Aspect_GridDrawMode              myCurDrawMode;
0107   double                           myCurXo;
0108   double                           myCurYo;
0109   double                           myCurAngle;
0110   double                           myCurXStep;
0111   double                           myCurYStep;
0112   double                           myCurXSize;
0113   double                           myCurYSize;
0114   double                           myCurOffSet;
0115 };
0116 
0117 #endif // _V3d_RectangularGrid_HeaderFile