~ubuntu-branches/ubuntu/natty/glbsp/natty

« back to all changes in this revision

Viewing changes to nodeview/info.cc

  • 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
//  INFO : Information Panel
 
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
// this includes everything we need
 
20
#include "defs.h"
 
21
 
 
22
 
 
23
#define INFO_BG_COLOR  fl_rgb_color(96)
 
24
 
 
25
 
 
26
//
 
27
// W_Info Constructor
 
28
//
 
29
W_Info::W_Info(int X, int Y, int W, int H, const char *label) : 
 
30
    Fl_Group(X, Y, W, H, label),
 
31
    num_segs(0)
 
32
{
 
33
  end();  // cancel begin() in Fl_Group constructor
 
34
 
 
35
  box(FL_FLAT_BOX);
 
36
 
 
37
//  color(INFO_BG_COLOR, INFO_BG_COLOR);
 
38
 
 
39
 
 
40
  X += 6;
 
41
  Y += 6;
 
42
 
 
43
  W -= 12;
 
44
  H -= 12;
 
45
 
 
46
  // ---- top section ----
 
47
  
 
48
  map_name = new Fl_Output(X+88, Y, W-88, 22, "Map Name:");
 
49
  map_name->align(FL_ALIGN_LEFT);
 
50
  add(map_name);
 
51
 
 
52
  Y += map_name->h() + 4;
 
53
 
 
54
  node_type = new Fl_Output(X+88, Y, W-88, 22, "Node Type:");
 
55
  node_type->align(FL_ALIGN_LEFT);
 
56
  add(node_type);
 
57
 
 
58
  Y += node_type->h() + 4;
 
59
 
 
60
  
 
61
  // ---- middle section ----
 
62
 
 
63
  Y += 16;
 
64
 
 
65
  ns_index = new Fl_Output(X+74, Y, 80, 22, "Node #    ");
 
66
  ns_index->align(FL_ALIGN_LEFT);
 
67
  add(ns_index);
 
68
 
 
69
  Y += ns_index->h() + 4;
 
70
 
 
71
 
 
72
  // bounding box
 
73
  
 
74
  bb_label = new Fl_Box(FL_NO_BOX, X, Y, W, 22, "Bounding Box:");
 
75
  bb_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
 
76
  add(bb_label);
 
77
  
 
78
  Y += bb_label->h() + 4;
 
79
 
 
80
  bb_x1 = new Fl_Output(X+32,   Y, 64, 22, "x1");
 
81
  bb_x2 = new Fl_Output(X+W-64, Y, 64, 22, "x2");
 
82
 
 
83
  bb_x1->align(FL_ALIGN_LEFT);
 
84
  bb_x2->align(FL_ALIGN_LEFT);
 
85
 
 
86
  add(bb_x1);
 
87
  add(bb_x2);
 
88
 
 
89
  Y += bb_x1->h() + 4;
 
90
 
 
91
  bb_y1 = new Fl_Output(X+32,   Y, 64, 22, "y1");
 
92
  bb_y2 = new Fl_Output(X+W-64, Y, 64, 22, "y2");
 
93
 
 
94
  bb_y1->align(FL_ALIGN_LEFT);
 
95
  bb_y2->align(FL_ALIGN_LEFT);
 
96
 
 
97
  add(bb_y1);
 
98
  add(bb_y2);
 
99
 
 
100
  Y += bb_y2->h() + 4;
 
101
 
 
102
 
 
103
  // partition line
 
104
 
 
105
  int save_Y = Y;
 
106
 
 
107
  pt_label = new Fl_Box(FL_NO_BOX, X, Y, W, 22, "Partition:");
 
108
  pt_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
 
109
  add(pt_label);
 
110
  
 
111
  Y += pt_label->h() + 4;
 
112
 
 
113
  pt_x  = new Fl_Output(X+32,   Y, 64, 22, "x");
 
114
  pt_dx = new Fl_Output(X+W-64, Y, 64, 22, "dx");
 
115
 
 
116
  pt_x ->align(FL_ALIGN_LEFT);
 
117
  pt_dx->align(FL_ALIGN_LEFT);
 
118
 
 
119
  add(pt_x);
 
120
  add(pt_dx);
 
121
 
 
122
  Y += pt_x->h() + 4;
 
123
 
 
124
  pt_y  = new Fl_Output(X+32,   Y, 64, 22, "y");
 
125
  pt_dy = new Fl_Output(X+W-64, Y, 64, 22, "dy");
 
126
 
 
127
  pt_y ->align(FL_ALIGN_LEFT);
 
128
  pt_dy->align(FL_ALIGN_LEFT);
 
129
 
 
130
  add(pt_y);
 
131
  add(pt_dy);
 
132
 
 
133
  Y += pt_dy->h() + 4;
 
134
 
 
135
 
 
136
  // seg list
 
137
 
 
138
  Y = save_Y;
 
139
  
 
140
  seg_label = new Fl_Box(FL_NO_BOX, X, Y, W, 22, "Seg List:");
 
141
  seg_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
 
142
  add(seg_label);
 
143
 
 
144
  Y += seg_label->h() + 4;
 
145
 
 
146
  seg_list = new Fl_Multiline_Output(X+10, Y, W-10, 96);
 
147
  add(seg_list);
 
148
 
 
149
  // keep 'em hidden
 
150
  seg_label->hide();
 
151
  seg_list->hide();
 
152
 
 
153
  Y += seg_list->h() + 4;
 
154
 
 
155
 
 
156
#if 1
 
157
  // resize control:
 
158
  Fl_Box *resize_control = new Fl_Box(FL_NO_BOX, x(), Y, w(), 4, NULL);
 
159
 
 
160
  add(resize_control);
 
161
  resizable(resize_control);
 
162
#endif 
 
163
  
 
164
  // ---- bottom section ----
 
165
 
 
166
  Y = y() + H - 22;
 
167
 
 
168
  mouse_x = new Fl_Output(X+28,   Y, 72, 22, "x");
 
169
  mouse_y = new Fl_Output(X+W-72, Y, 72, 22, "y");
 
170
 
 
171
  mouse_x->align(FL_ALIGN_LEFT);
 
172
  mouse_y->align(FL_ALIGN_LEFT);
 
173
 
 
174
  add(mouse_x);
 
175
  add(mouse_y);
 
176
 
 
177
  Y -= mouse_x->h() + 4;
 
178
 
 
179
  m_label = new Fl_Box(FL_NO_BOX, X, Y, W, 22, "Mouse Coords:");
 
180
  m_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
 
181
  add(m_label);
 
182
  
 
183
  Y -= m_label->h() + 4;
 
184
 
 
185
  grid_size = new Fl_Output(X+50, Y, 80, 22, "Scale:");
 
186
  grid_size->align(FL_ALIGN_LEFT);
 
187
  add(grid_size);
 
188
 
 
189
  Y -= grid_size->h() + 4;
 
190
 
 
191
}
 
192
 
 
193
//
 
194
// W_Info Destructor
 
195
//
 
196
W_Info::~W_Info()
 
197
{
 
198
}
 
199
 
 
200
int W_Info::handle(int event)
 
201
{
 
202
  return Fl_Group::handle(event);
 
203
}
 
204
 
 
205
 
 
206
//------------------------------------------------------------------------
 
207
 
 
208
void W_Info::SetMap(const char *name)
 
209
{
 
210
  char *upper = UtilStrUpper(name);
 
211
 
 
212
  map_name->value(upper);
 
213
 
 
214
  UtilFree(upper);
 
215
}
 
216
 
 
217
void W_Info::SetNodes(const char *type)
 
218
{
 
219
  node_type->value(type);
 
220
}
 
221
 
 
222
void W_Info::SetZoom(float zoom_mul)
 
223
{
 
224
  char buffer[60];
 
225
 
 
226
///  if (0.99 < zoom_mul && zoom_mul < 1.01)
 
227
///  {
 
228
///    grid_size->value("1:1");
 
229
///    return;
 
230
///  }
 
231
 
 
232
  if (zoom_mul < 0.99)
 
233
  {
 
234
    sprintf(buffer, "/ %1.3f", 1.0/zoom_mul);
 
235
  }
 
236
  else // zoom_mul > 1
 
237
  {
 
238
    sprintf(buffer, "x %1.3f", zoom_mul);
 
239
  }
 
240
 
 
241
  grid_size->value(buffer);
 
242
}
 
243
 
 
244
 
 
245
void W_Info::SetNodeIndex(int index)
 
246
{
 
247
  char buffer[60];
 
248
 
 
249
  sprintf(buffer, "%d", index);
 
250
  
 
251
  ns_index->label("Node #    ");
 
252
  ns_index->value(buffer);
 
253
 
 
254
  seg_label->hide();
 
255
  seg_list->hide();
 
256
 
 
257
  pt_label->show();
 
258
  pt_x ->show();
 
259
  pt_y ->show();
 
260
  pt_dx->show();
 
261
  pt_dy->show();
 
262
 
 
263
  redraw();
 
264
}
 
265
 
 
266
void W_Info::SetSubsectorIndex(int index)
 
267
{
 
268
  char buffer[60];
 
269
 
 
270
  sprintf(buffer, "%d", index);
 
271
  
 
272
  ns_index->label("Subsec #");
 
273
  ns_index->value(buffer);
 
274
 
 
275
  pt_label->hide();
 
276
  pt_x ->hide();
 
277
  pt_y ->hide();
 
278
  pt_dx->hide();
 
279
  pt_dy->hide();
 
280
 
 
281
  seg_label->show();
 
282
  seg_list->show();
 
283
 
 
284
  redraw();
 
285
}
 
286
 
 
287
void W_Info::SetCurBBox(const bbox_t *bbox)
 
288
{
 
289
  if (! bbox)
 
290
  {
 
291
    bb_x1->value("");
 
292
    bb_y1->value("");
 
293
    bb_x2->value("");
 
294
    bb_y2->value("");
 
295
 
 
296
    return;
 
297
  }
 
298
 
 
299
  char buffer[60]; 
 
300
 
 
301
  sprintf(buffer, "%d", bbox->minx);  bb_x1->value(buffer);
 
302
  sprintf(buffer, "%d", bbox->miny);  bb_y1->value(buffer);
 
303
  sprintf(buffer, "%d", bbox->maxx);  bb_x2->value(buffer);
 
304
  sprintf(buffer, "%d", bbox->maxy);  bb_y2->value(buffer);
 
305
}
 
306
 
 
307
void W_Info::SetPartition(const node_c *part)
 
308
{
 
309
  if (! part)
 
310
  {
 
311
    pt_x ->value("");
 
312
    pt_y ->value("");
 
313
    pt_dx->value("");
 
314
    pt_dy->value("");
 
315
 
 
316
    return;
 
317
  }
 
318
 
 
319
  char buffer[60]; 
 
320
 
 
321
  sprintf(buffer, "%d", part->x );  pt_x ->value(buffer);
 
322
  sprintf(buffer, "%d", part->y );  pt_y ->value(buffer);
 
323
  sprintf(buffer, "%d", part->dx);  pt_dx->value(buffer);
 
324
  sprintf(buffer, "%d", part->dy);  pt_dy->value(buffer);
 
325
}
 
326
 
 
327
void W_Info::SetMouse(double mx, double my)
 
328
{
 
329
  if (mx < -32767.0 || mx > 32767.0 ||
 
330
      my < -32767.0 || my > 32767.0)
 
331
  {
 
332
    mouse_x->value("off map");
 
333
    mouse_y->value("off map");
 
334
 
 
335
    return;
 
336
  }
 
337
 
 
338
  char x_buffer[60];
 
339
  char y_buffer[60];
 
340
 
 
341
  sprintf(x_buffer, "%1.1f", mx);
 
342
  sprintf(y_buffer, "%1.1f", my);
 
343
 
 
344
  mouse_x->value(x_buffer);
 
345
  mouse_y->value(y_buffer);
 
346
}
 
347
 
 
348
void W_Info::BeginSegList()
 
349
{
 
350
  num_segs = 0;
 
351
}
 
352
 
 
353
void W_Info::AddSeg(const seg_c *seg)
 
354
{
 
355
  if (num_segs < SEG_LIST_MAX)
 
356
  {
 
357
    seg_indices[num_segs++] = seg->index;
 
358
  }
 
359
}
 
360
 
 
361
void W_Info::EndSegList()
 
362
{
 
363
  char buffer[SEG_LIST_MAX * 32];
 
364
  char *line = buffer;
 
365
 
 
366
  buffer[0] = 0;
 
367
 
 
368
  for (int n = 0; n < num_segs; n++)
 
369
  {
 
370
    char num_buf[60];
 
371
 
 
372
    sprintf(num_buf, "%d", seg_indices[n]);
 
373
 
 
374
    int line_len = strlen(line);
 
375
    int num_len  = strlen(num_buf);
 
376
    
 
377
    // fits on the line?
 
378
    if (line_len + 1 + num_len <= 19)
 
379
    {
 
380
      if (*line != 0)
 
381
        strcat(buffer, " ");
 
382
    }
 
383
    else
 
384
    {
 
385
      strcat(buffer, "\n");
 
386
 
 
387
      line = buffer + strlen(buffer);
 
388
    }
 
389
 
 
390
    strcat(buffer, num_buf);
 
391
  }
 
392
 
 
393
  seg_list->value(buffer);
 
394
}
 
395