42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _Aspect_Grid_HeaderFile |
18 | #define _Aspect_Grid_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
42cf5bc1 |
23 | #include <Quantity_Color.hxx> |
24 | #include <Standard_Boolean.hxx> |
25 | #include <Aspect_GridDrawMode.hxx> |
25e59720 |
26 | #include <Standard_Transient.hxx> |
42cf5bc1 |
27 | |
25e59720 |
28 | class Aspect_Grid : public Standard_Transient |
42cf5bc1 |
29 | { |
475c2302 |
30 | DEFINE_STANDARD_RTTIEXT(Aspect_Grid, Standard_Transient) |
42cf5bc1 |
31 | public: |
32 | |
42cf5bc1 |
33 | //! defines the x Origin of the grid. |
ee2be2a8 |
34 | Standard_EXPORT void SetXOrigin (const Standard_Real anOrigin); |
42cf5bc1 |
35 | |
36 | //! defines the y Origin of the grid. |
ee2be2a8 |
37 | Standard_EXPORT void SetYOrigin (const Standard_Real anOrigin); |
42cf5bc1 |
38 | |
475c2302 |
39 | //! defines the orientation of the grid. |
ee2be2a8 |
40 | Standard_EXPORT void SetRotationAngle (const Standard_Real anAngle); |
42cf5bc1 |
41 | |
42 | //! Rotate the grid from a relative angle. |
ee2be2a8 |
43 | Standard_EXPORT void Rotate (const Standard_Real anAngle); |
42cf5bc1 |
44 | |
45 | //! Translate the grid from a relative distance. |
ee2be2a8 |
46 | Standard_EXPORT void Translate (const Standard_Real aDx, const Standard_Real aDy); |
42cf5bc1 |
47 | |
48 | //! Change the colors of the grid |
49 | Standard_EXPORT virtual void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor); |
50 | |
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 |
53 | //! X,Y. |
ee2be2a8 |
54 | Standard_EXPORT void Hit (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const; |
42cf5bc1 |
55 | |
56 | //! returns the point of the grid the closest to the point X,Y |
ee2be2a8 |
57 | Standard_EXPORT virtual void Compute (const Standard_Real X, const Standard_Real Y, Standard_Real& gridX, Standard_Real& gridY) const = 0; |
42cf5bc1 |
58 | |
59 | //! activates the grid. The Hit method will return |
60 | //! gridx and gridx computed according to the steps |
61 | //! of the grid. |
475c2302 |
62 | void Activate() { myIsActive = Standard_True; } |
42cf5bc1 |
63 | |
64 | //! deactivates the grid. The hit method will return |
65 | //! gridx and gridx as the enter value X & Y. |
475c2302 |
66 | void Deactivate() { myIsActive = Standard_False; } |
42cf5bc1 |
67 | |
68 | //! returns the x Origin of the grid. |
475c2302 |
69 | Standard_Real XOrigin() const { return myXOrigin; } |
42cf5bc1 |
70 | |
71 | //! returns the x Origin of the grid. |
475c2302 |
72 | Standard_Real YOrigin() const { return myYOrigin; } |
42cf5bc1 |
73 | |
74 | //! returns the x Angle of the grid. |
475c2302 |
75 | Standard_Real RotationAngle() const { return myRotationAngle; } |
42cf5bc1 |
76 | |
77 | //! Returns TRUE when the grid is active. |
475c2302 |
78 | Standard_Boolean IsActive() const { return myIsActive; } |
42cf5bc1 |
79 | |
80 | //! Returns the colors of the grid. |
81 | Standard_EXPORT void Colors (Quantity_Color& aColor, Quantity_Color& aTenthColor) const; |
82 | |
83 | //! Change the grid aspect. |
84 | Standard_EXPORT void SetDrawMode (const Aspect_GridDrawMode aDrawMode); |
85 | |
86 | //! Returns the grid aspect. |
475c2302 |
87 | Aspect_GridDrawMode DrawMode() const { return myDrawMode; } |
88 | |
42cf5bc1 |
89 | //! Display the grid at screen. |
475c2302 |
90 | Standard_EXPORT virtual void Display() = 0; |
42cf5bc1 |
91 | |
92 | //! Erase the grid from screen. |
475c2302 |
93 | Standard_EXPORT virtual void Erase() const = 0; |
42cf5bc1 |
94 | |
95 | //! Returns TRUE when the grid is displayed at screen. |
475c2302 |
96 | Standard_EXPORT virtual Standard_Boolean IsDisplayed() const = 0; |
42cf5bc1 |
97 | |
98 | Standard_EXPORT virtual void Init() = 0; |
99 | |
42cf5bc1 |
100 | protected: |
101 | |
475c2302 |
102 | //! Creates a new grid. By default this grid is not active. |
103 | Standard_EXPORT Aspect_Grid (const Standard_Real theXOrigin = 0.0, |
104 | const Standard_Real theYOrigin = 0.0, |
105 | const Standard_Real theRotationAngle = 0, |
106 | const Quantity_Color& theColor = Quantity_NOC_GRAY50, |
107 | const Quantity_Color& theTenthColor = Quantity_NOC_GRAY70); |
42cf5bc1 |
108 | |
109 | //! Updates the grid parameters. |
475c2302 |
110 | Standard_EXPORT virtual void UpdateDisplay() = 0; |
111 | |
112 | protected: |
42cf5bc1 |
113 | |
ee2be2a8 |
114 | Standard_Real myRotationAngle; |
115 | Standard_Real myXOrigin; |
116 | Standard_Real myYOrigin; |
42cf5bc1 |
117 | Quantity_Color myColor; |
118 | Quantity_Color myTenthColor; |
42cf5bc1 |
119 | Standard_Boolean myIsActive; |
120 | Aspect_GridDrawMode myDrawMode; |
121 | |
42cf5bc1 |
122 | }; |
123 | |
475c2302 |
124 | DEFINE_STANDARD_HANDLE(Aspect_Grid, Standard_Transient) |
125 | |
42cf5bc1 |
126 | #endif // _Aspect_Grid_HeaderFile |