1 // Created on: 1995-03-02
2 // Created by: Jean-Louis Frenkel
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _Aspect_Grid_HeaderFile
18 #define _Aspect_Grid_HeaderFile
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
23 #include <Quantity_Color.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <Aspect_GridDrawMode.hxx>
26 #include <Standard_Transient.hxx>
28 class Aspect_Grid : public Standard_Transient
30 DEFINE_STANDARD_RTTIEXT(Aspect_Grid, Standard_Transient)
33 //! defines the x Origin of the grid.
34 Standard_EXPORT void SetXOrigin (const Standard_Real anOrigin);
36 //! defines the y Origin of the grid.
37 Standard_EXPORT void SetYOrigin (const Standard_Real anOrigin);
39 //! defines the orientation of the grid.
40 Standard_EXPORT void SetRotationAngle (const Standard_Real anAngle);
42 //! Rotate the grid from a relative angle.
43 Standard_EXPORT void Rotate (const Standard_Real anAngle);
45 //! Translate the grid from a relative distance.
46 Standard_EXPORT void Translate (const Standard_Real aDx, const Standard_Real aDy);
48 //! Change the colors of the grid
49 Standard_EXPORT virtual void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor);
51 //! returns the point of the grid the closest to the point X,Y
52 //! if the grid is active. If the grid is not active returns
54 Standard_EXPORT void Hit (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const;
56 //! returns the point of the grid the closest to the point X,Y
57 Standard_EXPORT virtual void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const = 0;
59 //! activates the grid. The Hit method will return
60 //! gridx and gridx computed according to the steps
62 void Activate() { myIsActive = Standard_True; }
64 //! deactivates the grid. The hit method will return
65 //! gridx and gridx as the enter value X & Y.
66 void Deactivate() { myIsActive = Standard_False; }
68 //! returns the x Origin of the grid.
69 Standard_Real XOrigin() const { return myXOrigin; }
71 //! returns the x Origin of the grid.
72 Standard_Real YOrigin() const { return myYOrigin; }
74 //! returns the x Angle of the grid.
75 Standard_Real RotationAngle() const { return myRotationAngle; }
77 //! Returns TRUE when the grid is active.
78 Standard_Boolean IsActive() const { return myIsActive; }
80 //! Returns the colors of the grid.
81 Standard_EXPORT void Colors (Quantity_Color& aColor, Quantity_Color& aTenthColor) const;
83 //! Change the grid aspect.
84 Standard_EXPORT void SetDrawMode (const Aspect_GridDrawMode aDrawMode);
86 //! Returns the grid aspect.
87 Aspect_GridDrawMode DrawMode() const { return myDrawMode; }
89 //! Display the grid at screen.
90 Standard_EXPORT virtual void Display() = 0;
92 //! Erase the grid from screen.
93 Standard_EXPORT virtual void Erase() const = 0;
95 //! Returns TRUE when the grid is displayed at screen.
96 Standard_EXPORT virtual Standard_Boolean IsDisplayed() const = 0;
98 Standard_EXPORT virtual void Init() = 0;
100 //! Dumps the content of me into the stream
101 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
105 //! Creates a new grid. By default this grid is not active.
106 Standard_EXPORT Aspect_Grid (const Standard_Real theXOrigin = 0.0,
107 const Standard_Real theYOrigin = 0.0,
108 const Standard_Real theRotationAngle = 0,
109 const Quantity_Color& theColor = Quantity_NOC_GRAY50,
110 const Quantity_Color& theTenthColor = Quantity_NOC_GRAY70);
112 //! Updates the grid parameters.
113 Standard_EXPORT virtual void UpdateDisplay() = 0;
117 Standard_Real myRotationAngle;
118 Standard_Real myXOrigin;
119 Standard_Real myYOrigin;
120 Quantity_Color myColor;
121 Quantity_Color myTenthColor;
122 Standard_Boolean myIsActive;
123 Aspect_GridDrawMode myDrawMode;
127 DEFINE_STANDARD_HANDLE(Aspect_Grid, Standard_Transient)
129 #endif // _Aspect_Grid_HeaderFile