Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-28 10:19:12

0001 // Created on: 1995-03-02
0002 // Created by: Jean-Louis Frenkel
0003 // Copyright (c) 1995-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 _Aspect_Grid_HeaderFile
0018 #define _Aspect_Grid_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 
0022 #include <Quantity_Color.hxx>
0023 #include <Aspect_GridDrawMode.hxx>
0024 #include <Standard_Transient.hxx>
0025 
0026 class Aspect_Grid : public Standard_Transient
0027 {
0028   DEFINE_STANDARD_RTTIEXT(Aspect_Grid, Standard_Transient)
0029 public:
0030   //! defines the x Origin of the grid.
0031   Standard_EXPORT void SetXOrigin(const double anOrigin);
0032 
0033   //! defines the y Origin of the grid.
0034   Standard_EXPORT void SetYOrigin(const double anOrigin);
0035 
0036   //! defines the orientation of the grid.
0037   Standard_EXPORT void SetRotationAngle(const double anAngle);
0038 
0039   //! Rotate the grid from a relative angle.
0040   Standard_EXPORT void Rotate(const double anAngle);
0041 
0042   //! Translate the grid from a relative distance.
0043   Standard_EXPORT void Translate(const double aDx, const double aDy);
0044 
0045   //! Change the colors of the grid
0046   Standard_EXPORT virtual void SetColors(const Quantity_Color& aColor,
0047                                          const Quantity_Color& aTenthColor);
0048 
0049   //! returns the point of the grid the closest to the point X,Y
0050   //! if the grid is active. If the grid is not active returns
0051   //! X,Y.
0052   Standard_EXPORT void Hit(const double X, const double Y, double& gridX, double& gridY) const;
0053 
0054   //! returns the point of the grid the closest to the point X,Y
0055   Standard_EXPORT virtual void Compute(const double X,
0056                                        const double Y,
0057                                        double&      gridX,
0058                                        double&      gridY) const = 0;
0059 
0060   //! activates the grid. The Hit method will return
0061   //! gridx and gridx computed according to the steps
0062   //! of the grid.
0063   void Activate() { myIsActive = true; }
0064 
0065   //! deactivates the grid. The hit method will return
0066   //! gridx and gridx as the enter value X & Y.
0067   void Deactivate() { myIsActive = false; }
0068 
0069   //! returns the x Origin of the grid.
0070   double XOrigin() const { return myXOrigin; }
0071 
0072   //! returns the x Origin of the grid.
0073   double YOrigin() const { return myYOrigin; }
0074 
0075   //! returns the x Angle of the grid.
0076   double RotationAngle() const { return myRotationAngle; }
0077 
0078   //! Returns TRUE when the grid is active.
0079   bool IsActive() const { return myIsActive; }
0080 
0081   //! Returns the colors of the grid.
0082   Standard_EXPORT void Colors(Quantity_Color& aColor, Quantity_Color& aTenthColor) const;
0083 
0084   //! Change the grid aspect.
0085   Standard_EXPORT void SetDrawMode(const Aspect_GridDrawMode aDrawMode);
0086 
0087   //! Returns the grid aspect.
0088   Aspect_GridDrawMode DrawMode() const { return myDrawMode; }
0089 
0090   //! Display the grid at screen.
0091   Standard_EXPORT virtual void Display() = 0;
0092 
0093   //! Erase the grid from screen.
0094   Standard_EXPORT virtual void Erase() const = 0;
0095 
0096   //! Returns TRUE when the grid is displayed at screen.
0097   Standard_EXPORT virtual bool IsDisplayed() const = 0;
0098 
0099   Standard_EXPORT virtual void Init() = 0;
0100 
0101   //! Dumps the content of me into the stream
0102   Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0103 
0104 protected:
0105   //! Creates a new grid. By default this grid is not active.
0106   Standard_EXPORT Aspect_Grid(const double          theXOrigin       = 0.0,
0107                               const double          theYOrigin       = 0.0,
0108                               const double          theRotationAngle = 0,
0109                               const Quantity_Color& theColor         = Quantity_NOC_GRAY50,
0110                               const Quantity_Color& theTenthColor    = Quantity_NOC_GRAY70);
0111 
0112   //! Updates the grid parameters.
0113   Standard_EXPORT virtual void UpdateDisplay() = 0;
0114 
0115 protected:
0116   double              myRotationAngle;
0117   double              myXOrigin;
0118   double              myYOrigin;
0119   Quantity_Color      myColor;
0120   Quantity_Color      myTenthColor;
0121   bool                myIsActive;
0122   Aspect_GridDrawMode myDrawMode;
0123 };
0124 
0125 #endif // _Aspect_Grid_HeaderFile