UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZtStairs.H
1 /* ZtStairs.H */
2 /* $Id: ZtStairs.H,v 1.6 2004/02/17 13:53:38 vlad Exp $ */
3 #ifndef __ZtStairs_H
4 #define __ZtStairs_H
5 
6 #include <mix/DoubleAr.H>
7 #include <zm/ZtTablet.H>
8 
9 
10 /***********************************************************************
11  * Object to draw editable stairs: one argument point -> one stair (two
12  * points of function). Allows to change asynchronously argument array.
13  ***********************************************************************/
14 class ZtStairs: public ZtTablet
15 {
16 protected:
17 
18  Logic detached; /* TRUE if no data */
19  Logic editable; /* allow to change function visually */
20  ZDimension arg_orient; /* zdHor means that argument axis is horiz. */
21  DoubleAr *arg; /* N points */
22  DoubleAr *func; /* N+1 points */
23  XSegmentAr lines; /* temporal buffer for segments being drawn */
24  XSegmentAr borders;/* temporal buffer for segments on border of rect */
25 
26  /* Proceed one segment of a curve in rectangle (xr,xr+wr)-(yr,yr+hr). */
27  void add_segment (float x[2], float y[2],
28  float xr, float yr, float wr, float hr);
29 
30 public:
31 
32  /* Special graphics context for line drawing */
33  ZGEnv line;
34 
35  /* Constructor. Argument zdVertical means nyid is arg and
36  nxid is function; zdHorizontal means another orientation. */
37  ZtStairs (ZtMain* pManager,
38  ZGroupId pxid, ZGroupId pyid,
39  ZGroupId nxid, ZGroupId nyid,
40  ZDimension argument);
41 
42  /* rArg and rFunc are changed inside object */
43  void attach_data (DoubleAr& rArg, DoubleAr& rFunc);
44  void detach_data ();
45 
46  /* Direct draw procedure: if size, place or parameters are changed */
47  virtual void redraw ();
48 
49  /* Find internal index of stair by (nx,ny) pair */
50  unsigned index (float nx, float ny);
51 
52  /* Callback for end of selection */
53  virtual void point (float nx, float ny);
54 
55  /* Get stair argument range and stair value */
56  void stair (float nx, float ny,
57  double fArg[2], double& fFunc);
58 
59  /* Insert point */
60  virtual void insert (unsigned index, double fArg, double fFunc);
61 
62  /* Remove point */
63  virtual void remove (unsigned index);
64 
65  /* Number of stairs */
66  int n_of_stairs () const;
67 
68  /* Get stair value */
69  double stair_value (int i) const;
70 
71  /* Set stair value */
72  void set_value (int i, double d);
73 
75  virtual const char* class_id () const;
76 
77 };
78 
79 
80 #endif /* ZtStairs.H */
Definition: ZBase.H:156
Definition: ZtTablet.H:15
virtual void redraw()
Definition: ZtMain.H:32
ZNCoordSlave & nx() const
Definition: geometry.H:16
Definition: DoubleAr.H:14
Definition: ZtStairs.H:14
virtual const char * class_id() const