~ubuntu-branches/ubuntu/precise/glbsp/precise

« back to all changes in this revision

Viewing changes to nodeview/grid.h

  • Committer: Bazaar Package Importer
  • Author(s): Darren Salt
  • Date: 2008-01-30 13:33:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080130133349-kgojg33vyiu8xbvp
Tags: 2.24-1
* New upstream release.
* Bumped the lib soname and the library package name due to one silly
  little binary incompatibility caused by changes in an exported struct.
  (Safe; nothing else currently in the archive has ever used libglbsp2.)
* Removed my patches since they're all applied upstream.
* Updated the list of documentation files.
* Build-time changes:
  - Switched from dh_movefiles to dh_install.
  - Updated my makefile to cope with upstream changes.
  - Corrected for debian-rules-ignores-make-clean-error.
  - Corrected for substvar-source-version-is-deprecated.
  - Link libglbsp, rather than glbsp, with libm and libz.
* Fixed shlibdeps. (Closes: #460387)
* Bumped standards version to 3.7.3 (no other changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------
 
2
//  GRID : Draws the map (lines, nodes, etc)
 
3
//------------------------------------------------------------------------
 
4
//
 
5
//  GL-Node Viewer (C) 2004-2007 Andrew Apted
 
6
//
 
7
//  This program is free software; you can redistribute it and/or
 
8
//  modify it under the terms of the GNU General Public License
 
9
//  as published by the Free Software Foundation; either version 2
 
10
//  of the License, or (at your option) any later version.
 
11
//
 
12
//  This program is distributed in the hope that it will be useful,
 
13
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
//  GNU General Public License for more details.
 
16
//
 
17
//------------------------------------------------------------------------
 
18
 
 
19
#ifndef __NODEVIEW_GRID_H__
 
20
#define __NODEVIEW_GRID_H__
 
21
 
 
22
class W_Grid : public Fl_Widget
 
23
{
 
24
public:
 
25
  W_Grid(int X, int Y, int W, int H, const char *label = 0);
 
26
  ~W_Grid();
 
27
 
 
28
  void SetZoom(int new_zoom);
 
29
  // changes the current zoom factor.
 
30
 
 
31
  void SetPos(double new_x, double new_y);
 
32
  // changes the current position.
 
33
 
 
34
  void SetPath(path_c *p) { path = p; }
 
35
  //  give a path for the grid to draw
 
36
 
 
37
  void ClearPath() { SetPath(NULL); }
 
38
 
 
39
  void FitBBox(double lx, double ly, double hx, double hy);
 
40
  // set zoom and position so that the bounding area fits.
 
41
 
 
42
  void MapToWin(double mx, double my, int *X, int *Y) const;
 
43
  // convert a map coordinate into a window coordinate, using
 
44
  // current grid position and zoom factor.
 
45
 
 
46
  void WinToMap(int X, int Y, double *mx, double *my) const;
 
47
  // convert a map coordinate into a window coordinate, using
 
48
  // current grid position and zoom factor.
 
49
 
 
50
public:
 
51
  int handle(int event);
 
52
  // FLTK virtual method for handling input events.
 
53
 
 
54
  void resize(int X, int Y, int W, int H);
 
55
  // FLTK virtual method for resizing.
 
56
 
 
57
private:
 
58
  void draw();
 
59
  // FLTK virtual method for drawing.
 
60
 
 
61
  void draw_grid(double spacing, int ity);
 
62
  void draw_partition(const node_c *nd, int ity);
 
63
  void draw_bbox(const bbox_t *bbox, int ity);
 
64
  void draw_all_partitions();
 
65
 
 
66
  void draw_node(const node_c *nd, int pos, bool on_route);
 
67
  void draw_child(const child_t *ch, int pos, bool on_route);
 
68
  void draw_subsector(const subsec_c *sub, int pos, bool on_route);
 
69
  void draw_path();
 
70
 
 
71
  bool set_seg_color(seg_c *seg, bool on);
 
72
  void draw_line(double x1, double y1, double x2, double y2);
 
73
 
 
74
  void scroll(int dx, int dy);
 
75
 
 
76
  void new_node_or_sub(void);
 
77
 
 
78
public:
 
79
  int handle_key(int key);
 
80
 
 
81
  void handle_mouse(int wx, int wy);
 
82
 
 
83
private:
 
84
  int zoom;
 
85
  // zoom factor: (2 ^ (zoom/2)) pixels per 512 units on the map
 
86
 
 
87
  double zoom_mul;
 
88
  // derived from 'zoom'.
 
89
 
 
90
  static const int MIN_GRID_ZOOM = 3;
 
91
  static const int DEF_GRID_ZOOM = 18;  // 1:1 ratio
 
92
  static const int MAX_GRID_ZOOM = 30;
 
93
 
 
94
  double mid_x;
 
95
  double mid_y;
 
96
 
 
97
  int grid_MODE;
 
98
  int partition_MODE;
 
99
  int bbox_MODE;
 
100
  int miniseg_MODE;
 
101
  int shade_MODE;
 
102
 
 
103
  path_c *path;
 
104
 
 
105
  static const int MAX_ROUTE = 2000;
 
106
 
 
107
  static const char RT_RIGHT = 0;
 
108
  static const char RT_LEFT  = 1;
 
109
 
 
110
  char *visit_route;
 
111
  int route_len;
 
112
 
 
113
  bool descend_by_mouse(int wx, int wy);  // true if OK
 
114
  bool descend_tree(char side);  // true if OK
 
115
 
 
116
  void lowest_node(node_c **nd, subsec_c **sub, bbox_t **bbox);
 
117
 
 
118
  static inline int GRID_FIND(double x, double y)
 
119
  {
 
120
    return int(x - fmod(x,y) + (x < 0) ? y : 0);
 
121
  }
 
122
 
 
123
  static const int O_TOP    = 1;
 
124
  static const int O_BOTTOM = 2;
 
125
  static const int O_LEFT   = 4;
 
126
  static const int O_RIGHT  = 8;
 
127
 
 
128
  static int MAP_OUTCODE(double x, double y,
 
129
      double lx, double ly, double hx, double hy)
 
130
  {
 
131
    return
 
132
      ((y < ly) ? O_BOTTOM : 0) |
 
133
      ((y > hy) ? O_TOP    : 0) |
 
134
      ((x < lx) ? O_LEFT   : 0) |
 
135
      ((x > hx) ? O_RIGHT  : 0);
 
136
  }
 
137
 
 
138
};
 
139
 
 
140
#endif /* __NODEVIEW_GRID_H__ */