UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ZtRubberSlRect.H
1 /* ZtRubberSlRect.H */
2 /* $Id: ZtRubberSlRect.H,v 3.4 2004/02/17 13:53:38 vlad Exp $ */
3 #ifndef __ZtRubberSlRect_H
4 #define __ZtRubberSlRect_H
5 
6 
7 #include <zm/ZtRubberRect.H>
8 
9 
10 /*************************************************************
11  * Object for drawing slanted rubber box. Useful for
12  * arbitrary slanting rectangle selection.
13  *************************************************************/
15 {
16 public:
17 
18  ZtRubberSlRect (ZtMain* pManager,
19  ZGroupId pxid, ZGroupId pyid,
20  ZGroupId nxid, ZGroupId nyid);
21 
22  /* Callback for end of selection pass n=4 corner points (x,y) */
23  virtual void box (int pnts_n, float xcor[], float ycor[]);
24 
25  /* Event processing status:
26  ziProcessed - if event processing has been finished (ungrab input);
27  ziGrabInput - if event processing must be continued (grab input);
28  ziSkipped - if this event is not processed. */
29  virtual ZInputStatus input (const XEvent* xev);
30 
31  /* Draw last selected rectangle */
32  virtual void redraw ();
33 
34  /* Set draw flag */
35  virtual void draw_last_box (Logic draw_flag);
36 
37  /* Set help lines allocated statically */
38  void set_help_msgs (const char* msg1 = NULL,
39  const char* msg2 = NULL);
40 
41  /* Graphics environment of permanent area drawing */
42  ZGEnv geLastBox;
43 
45  virtual const char* class_id () const;
46 
47 protected:
48 
49  /* Calculate distance between line (p1,p2) and point p0 */
50  float distance_point_to_line (ZPoint& p0, ZPoint& p1, ZPoint& p2);
51 
52  /* Calculate corner coords for 2 points and half of width value */
53  void slanting_rect_corners (ZPoint& p1, ZPoint& p2, float hw,
54  float xc[4], float yc[4]);
55 
56  /* Draw slanting rectangle unconditionally */
57  void draw_slanting_rect (ZPoint& p1, ZPoint& p2, float hw);
58 
59  /* Draw closed tetragonal figure with clipping */
60  void draw_clipped (ZGEnv& genv, float xcor[4], float ycor[4]);
61 
62 private:
63 
64  Logic bDrawn; /* rubber rect need to be erased */
65  int state; /* 1 - first point is to be selected;
66  2 - second point is to be selected;
67  3 - half-width is to be selected. */
68  ZPoint zp1; /* first point selected (or current value) */
69  ZPoint zp2; /* second point selected (or current value) */
70  const char *szHelp[2]; /* supply user with online state-dep.help */
71  float half_width; /* half of width */
72  float xc[4], yc[4]; /* last selected corner natural coords */
73  Logic bDrawLast; /* draw last selection or don't? */
74 
75 };
76 
77 
78 
79 #endif /* ZtRubberSlRect.H */
Definition: ZBase.H:156
virtual const char * class_id() const
Definition: ZtRubberSlRect.H:14
Definition: ZtMain.H:32
virtual void redraw()
Definition: ZBase.H:30
Definition: ZtRubberRect.H:16
virtual ZInputStatus input(const XEvent *xev)