SCV  4.2.1
Simple Components for Visual
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Scissor.h
Go to the documentation of this file.
1 #ifndef __SCV_SCISSOR_H__
2 #define __SCV_SCISSOR_H__
3 
4 #include "Singleton.h"
5 #include "Point.h"
6 
7 namespace scv {
8 
9 class Scissor : public Singleton<Scissor> {
10 friend class Singleton<Scissor>;
11 public:
12  class Info {
13  public:
14  Info(void);
15  Info(GLint x, GLint y, GLsizei width, GLsizei height);
16  //[<number>,<number>,<number>,<number>]
17  Info(const std::string &str);
18 
19  bool isInside(const Point &p) const;
20  inline bool isValid(void) const {
21  return (height == -1 || height == -1) ? false : true;
22  }
23 
24  inline Point getPosition(void) {
25  return Point(x, y);
26  }
27 
28  inline void operator+=(const Point &p) {
29  x += p.x; y += p.y;
30  }
31 
32  friend std::ostream& operator<<(std::ostream& stream, const Info& rhs) {
33  return (stream << rhs.x << "," << rhs.y << "," << rhs.width << "," << rhs.height);
34  }
35 
36  GLint x, y;
37  GLsizei width, height;
38  };
39 
40  void pushScissor(const Info &scissor);
41  void popScissor(void);
42  const Info& currentScissor(void) const;
43 
44 private:
45  Scissor(void) {}
46 
47  std::deque<Info> _scissorStack;
48 };
49 
50 } // namespace scv
51 
52 #endif // __SCV_SCISSOR_H__