UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZPlacement.H
1 // ZPlacement.H $Revision: 1.4 $ $Date: 2003/12/28 14:42:18 $
2 
3 #if !defined __ZPlacement_H
4 
5 #define __ZPlacement_H
6 
7 
8 #include <zm/ZPixelCoord.H>
9 
10 
11 /*************************************************************
12  * Base placement of groups in one dimension.
13  *************************************************************/
15 {
16 protected:
17 
18  /* Master of all groups */
19  ZPCoordMaster &master;
20 
21 public:
22 
23  /* Link with master of this dimension */
24  ZPlacement (ZPCoordMaster& rMaster)
25  : master(rMaster) {};
26 
27  /* Just to make compiler happy */
28  virtual ~ZPlacement ();
29 
30  /* The main placement procedure.
31  * Input:
32  * pc[0] -- start coord;
33  * pc[1] -- end coord of allowed area;
34  * Return:
35  * 0 - OK, successful placement;
36  * negative - this count of pixels are needed to add to area
37  * place all groups;
38  */
39  virtual int place (int pc[2]) = 0;
40 
41 };
42 
43 
44 /*************************************************************
45  * Typical proportional placement of groups: indentation on
46  * borders and equal delta between groups. Each group uses
47  * proportional space under itself.
48  *************************************************************/
49 
51 {
52  /* Predefined */
53  ZGroupId id; /* id of group */
54  float part; /* user-defined fraction > 0 */
55 
56  /* Calculated */
57  enum{
58  non_placed = 0, test_placed, fix_placed
59  } placed;
60  Logic empty; /* TRUE if group is empty -- skip during calculation */
61  float size; /* size of group in pixels */
62  int min_size; /* minimum size due to linked group */
63 };
64 
65 
66 #define AnyType ZPropPlacedType
67 #define AnyAr ZPropPlacedAr
68 #define AnyFormatSpec "\n[%d]: id=%d part=%g placed=%d(1-test,2-fixed) size=%g min_size=%d%s"
69 #define AnyPrintList i, item.id, item.part, item.placed, item.size, \
70  item.min_size, item.empty?" <empty>": ""
71 #include <mix/AnyAr.H>
72 
73 
74 class ZPropPlacement : public ZPlacement
75 {
76 private:
77 
78  /* Control parameters */
79  int iLeftOffset; /* pixels */
80  int iRightOffset; /* pixels */
81  int iDelta; /* pixels */
82  ZPropPlacedAr ar; /* groups and calculation of its sizes */
83 
85  void place_group (ZGroupId gid, int c[2]);
86 
87 public:
88 
89  /* Link with master of this dimension */
90  ZPropPlacement (ZPCoordMaster& master);
91 
92  /* Clear object from groups */
93  void reset ();
94 
95  /* Includes one more group at the end of list */
96  void add (ZGroupId gid, float fraction);
97 
98  /* set - get */
99  void set_left_offset (int leftOffset);
100  void set_right_offset (int rightOffset);
101  void set_delta (int delta);
102 
103  int get_left_offset () const;
104  int get_right_offset () const;
105  int get_delta () const;
106 
107  /* The main placement procedure.
108  * Input:
109  * pc[0] -- start coord;
110  * pc[1] -- end coord of allowed area;
111  * Return:
112  * 0 - OK, successful placement;
113  * negative - this count of pixels are needed to add to area
114  * place all groups;
115  * Known bugs of method:
116  * 1. Computed sizes may slightly differ from ideal (1-3 pixels),
117  * but limited size groups (FixedSize, MinSize) have always right
118  * size;
119  * 2. The last group may have greater size than needed (1-3 pixels).
120  */
121  virtual int place (int pc[2]);
122 
123 };
124 
125 
126 #endif // ZPlacement.H
Definition: ZPlacement.H:14
Definition: ZPlacement.H:50
Definition: ZPlacement.H:74
Definition: ZPixelCoord.H:174