UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
XDR.H
1 // XDR.H $Revision: 1.4 $ $Date: 1998/05/13 15:59:40 $
2 
3 #if !defined __XDR_H
4 
5 #define __XDR_H
6 
7 #include <mix/Types.h>
8 #include <zm/XGOps.H>
9 
10 
11 /*************************************************************
12  The next flags if will be ORed defines coordinates
13  convertion inside this rectangle. By default (SWAP_YX|
14  DIRECT_X|DIRECT_Y) is set. In fact they are used for axis
15  orientation.
16 
17  Rectange is defined by its corners (x1,y1)-(x2,y2) where
18  x1 = x_left; y1 = y_top;
19  x2 = x_left + width - 1; y2 = y_top + height - 1;
20 
21  Virual coordinates system (cs):
22 
23  (0,0) u
24  +--->
25  |
26  |
27  v V
28 
29  Convertions to real x and y coordinates:
30 
31  1) DIRECT_X|DIRECT_Y|SWAP_YX --> (x=u; y=v)
32  2) DIRECT_X|REVERT_Y|SWAP_YX --> (x=u; y=(y1+y2)-v)
33  3) REVERT_X|DIRECT_Y|SWAP_YX --> (x=(x1+x2)-u; y=v)
34  4) REVERT_X|REVERT_Y|SWAP_YX --> (x=(x1+x2)-u; y=(y1+y2)-v)
35  5) DIRECT_X|DIRECT_Y|SWAP_XY --> (x=v; y=u)
36  6) DIRECT_X|REVERT_Y|SWAP_XY --> (x=v; y=(x1+x2)-u)
37  7) REVERT_X|DIRECT_Y|SWAP_XY --> (x=(y1+y2)-v; y=u)
38  8) REVERT_X|REVERT_Y|SWAP_XY --> (x=(y1+y2)-v; y=(x1+x2)-u)
39 
40 */
41 
42 /* Axis direction */
43 #define DIRECT_X 0
44 #define DIRECT_Y 0
45 #define REVERT_X (1<<0)
46 #define REVERT_Y (1<<1)
47 
48 /* Axis swapping */
49 #define SWAP_YX 0
50 #define SWAP_XY (1<<2)
51 
52 
53 /*************************************************************
54  * X Drawable Rectangle
55  *************************************************************/
56 
57 class XDR : public XGOps
58 {
59 protected:
60 
61  int width, height; // width and height of rectangle
62  int x_left, y_top; // left top corner's coordinate in window
63  int cs_mask; // orientation flag: ORed DIRECT_? and REVERT_?
64 
65 public:
66 
67  XDR (const XDO& xdo);
68 
69  virtual void set_width (int w);
70  virtual void set_height (int h);
71  virtual void set_sizes (int w, int h);
72  virtual void set_xy (int x, int y);
73 
74  virtual int get_width () const;
75  virtual int get_height () const;
76  virtual int get_x () const;
77  virtual int get_y () const;
78 
79  // Check real coordinates
80  virtual Logic is_inside (int x, int y) const;
81  virtual Logic force_inside (int& x, int& y) const;
82 
83  // Set and get axis orientation
84  void set_cs (int cs);
85  int get_cs () const;
86 
87  virtual void fill_background ();
88 
89  // Coordinates system convertion
90  void cs_out (int u, int v, int& x, int& y); // (u,v)-->(x,y)
91  void cs_in (int x, int y, int& u, int& v); // (x,y)-->(u,v)
92 
93  // Drawing operations with defined axis orientation
94  // u(old x), v(old y) -- abstract coordinates
95  virtual void draw_line (int u1, int v1, int u2, int v2);
96  virtual void draw_rect1 (int u1, int v1, int w, int h);
97  virtual void draw_rect2 (int u1, int v1, int u2, int v2);
98  virtual void draw_point (int u, int v);
99  virtual void fill_rect1 (int u1, int v1, int w, int h);
100  virtual void fill_rect2 (int u1, int v1, int u2, int v2);
101 
102  virtual void expose ();
103 };
104 
105 
106 #endif // XDR.H
Definition: XDO.H:16
Definition: XDR.H:57
Definition: XGOps.H:31