OpenLexocad  27.0
ViewInterface.h
Go to the documentation of this file.
1 
9 #ifndef VIEWINTERFACE_H
10 #define VIEWINTERFACE_H
11 
12 #include <Core/core_defines2.h>
13 #include <Geom/Lin.h>
14 #include <Geom/Pnt.h>
15 #include <Geom/Rect.h>
16 
17 
18 namespace Core
19 {
20 class CViewport;
21 class CAbstractPreviewInt;
22 
24 {
27 };
28 
29 
30 
36 {
37 public:
38  virtual Geom::Rect map2Scene(const Core::CViewport& viewport) = 0;
39  virtual Geom::Rect map2Scene(const Geom::Rect& rect) = 0;
40  virtual Geom::Pnt map2Scene(const Geom::Pnt& p) = 0;
41  virtual Geom::Pnt map2Scene(int x, int y) = 0;
42 
43  virtual Geom::Rect map2View(const Geom::Rect& rect) = 0;
44  virtual Geom::Pnt map2View(const Geom::Pnt& p) = 0;
45  virtual Geom::Pnt map2View(double x, double y) = 0;
46 
47  virtual void fit(const Geom::Rect& rect_scene) = 0;
48  virtual void fit(double x, double y, double w, double h) = 0;
49 
50  virtual void centerView(const Geom::Pnt& p) = 0;
51  virtual void centerView(double x, double y) = 0;
52  virtual void translateView(const Geom::Pnt& dp) = 0;
53  virtual void translateView(double dx, double dy) = 0;
54  virtual void scaleView(double factor) = 0;
55 
56  virtual void zoom(double z, bool storeView = true) = 0;
57 
58  virtual void setTheSceneRect(const Geom::Rect& rect) = 0;
59  virtual Geom::Rect getSceneRect(void) = 0;
60  virtual CViewport getViewport(void) = 0;
61 
62  virtual void updateView(void) = 0;
63 
64 
65  // cursor interface
66  //
67  virtual void setCursor_DefaultViewing(void) = 0;
68  virtual void setCursor_DefaultDrawing(void) = 0;
69  virtual void setCursor_Panning(void) = 0;
70  virtual void setCursor_Blank(void) = 0;
71  virtual void setCursor_DND(void) = 0;
72  virtual void setCursor_Special(SpecialCursor c) = 0;
73 
74  virtual Geom::Pnt getCursorPosition_Viewport(void) = 0;
75  virtual Geom::Pnt getCursorPosition_Scene(void) = 0;
76  virtual void setCursorPosition(int local_x, int local_y) = 0;
77  virtual void setTheFocus(void) = 0;
78 
79  virtual void pushCursor(void) = 0;
80  virtual void popCursor(void) = 0;
81 
82 
83  // preview interface
84  //
85  virtual CAbstractPreviewInt* startPreview(const std::string& type) = 0;
86  virtual void updateAllPreviewsDest(double x, double y) = 0;
87  virtual void stopAllPreviews(void) = 0;
88  virtual void hideAllPreviews(void) = 0;
89  virtual void showAllPreviews(void) = 0;
90 
91  virtual void startSelectionBand(int x, int y, int style = 0) = 0;
92  virtual void stopSelectionBand(void) = 0;
93 
94 
95 
96 // debugging interface
97 #ifndef NDEBUG
98 public:
99  virtual void DEBUG_addRectangle(const Geom::Rect& rect, int r, int g, int b) = 0;
100  virtual void DEBUG_addLine(const Geom::Pnt& p1, const Geom::Pnt& p2, int r, int g, int b) = 0;
101  virtual void DEBUG_addLine(const Geom::Lin& l, int r, int g, int b) = 0;
102  virtual void DEBUG_addArc(const Geom::Pnt& center, double radius, double startAngle_rad, double arcLengeth_rad, int r, int g, int b) = 0;
103  virtual void DEBUG_clear(void) = 0;
104 #endif
105 };
106 
107 
113 {
114 public:
115  int width;
116  int height;
117 
118 
120  {
121  width = 0;
122  height = 0;
123  }
124 
125  Geom::Rect toRect() { return Geom::Rect(0.0, 0.0, width, height); }
126 
127  bool isValid()
128  {
129  if (width > 0 && height > 0)
130  return true;
131  else
132  return false;
133  }
134 
135  bool contains(const Geom::Pnt& point)
136  {
137  if (!isValid())
138  return false;
139 
140  if (point.x() < 0 || point.x() > width)
141  return false;
142 
143  if (point.y() < 0 || point.y() > height)
144  return false;
145  else
146  return true;
147  }
148 };
149 
150 
151 
152 } // namespace Core
153 
154 
155 
156 #endif
#define CORE_EXPORT
Definition: core_defines2.h:10
Geom::Rect toRect()
Definition: ViewInterface.h:125
Defines a non-persistent 3D Cartesian point.
Definition: Pnt.h:42
double y() const
For this point, returns its X coordinate.
SpecialCursor
Definition: ViewInterface.h:23
CViewport()
Definition: ViewInterface.h:119
Definition: Rect.h:28
double x() const
For this point, returns its X coordinate.
Definition: Lin.h:50
Definition: Base.h:19
bool contains(const Geom::Pnt &point)
Definition: ViewInterface.h:135
bool isValid()
Definition: ViewInterface.h:127
Definition: ViewInterface.h:25
int width
Definition: ViewInterface.h:115
Definition: ViewInterface.h:35
Definition: ViewInterface.h:112
Definition: ViewInterface.h:26
int height
Definition: ViewInterface.h:116