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