1
//------------------------------------------------------------------------
2
// INFO : Information Panel
3
//------------------------------------------------------------------------
5
// GL-Node Viewer (C) 2004-2007 Andrew Apted
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.
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.
17
//------------------------------------------------------------------------
19
// this includes everything we need
23
#define INFO_BG_COLOR fl_rgb_color(96)
29
W_Info::W_Info(int X, int Y, int W, int H, const char *label) :
30
Fl_Group(X, Y, W, H, label),
33
end(); // cancel begin() in Fl_Group constructor
37
// color(INFO_BG_COLOR, INFO_BG_COLOR);
46
// ---- top section ----
48
map_name = new Fl_Output(X+88, Y, W-88, 22, "Map Name:");
49
map_name->align(FL_ALIGN_LEFT);
52
Y += map_name->h() + 4;
54
node_type = new Fl_Output(X+88, Y, W-88, 22, "Node Type:");
55
node_type->align(FL_ALIGN_LEFT);
58
Y += node_type->h() + 4;
61
// ---- middle section ----
65
ns_index = new Fl_Output(X+74, Y, 80, 22, "Node # ");
66
ns_index->align(FL_ALIGN_LEFT);
69
Y += ns_index->h() + 4;
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);
78
Y += bb_label->h() + 4;
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");
83
bb_x1->align(FL_ALIGN_LEFT);
84
bb_x2->align(FL_ALIGN_LEFT);
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");
94
bb_y1->align(FL_ALIGN_LEFT);
95
bb_y2->align(FL_ALIGN_LEFT);
107
pt_label = new Fl_Box(FL_NO_BOX, X, Y, W, 22, "Partition:");
108
pt_label->align(FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
111
Y += pt_label->h() + 4;
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");
116
pt_x ->align(FL_ALIGN_LEFT);
117
pt_dx->align(FL_ALIGN_LEFT);
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");
127
pt_y ->align(FL_ALIGN_LEFT);
128
pt_dy->align(FL_ALIGN_LEFT);
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);
144
Y += seg_label->h() + 4;
146
seg_list = new Fl_Multiline_Output(X+10, Y, W-10, 96);
153
Y += seg_list->h() + 4;
158
Fl_Box *resize_control = new Fl_Box(FL_NO_BOX, x(), Y, w(), 4, NULL);
161
resizable(resize_control);
164
// ---- bottom section ----
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");
171
mouse_x->align(FL_ALIGN_LEFT);
172
mouse_y->align(FL_ALIGN_LEFT);
177
Y -= mouse_x->h() + 4;
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);
183
Y -= m_label->h() + 4;
185
grid_size = new Fl_Output(X+50, Y, 80, 22, "Scale:");
186
grid_size->align(FL_ALIGN_LEFT);
189
Y -= grid_size->h() + 4;
200
int W_Info::handle(int event)
202
return Fl_Group::handle(event);
206
//------------------------------------------------------------------------
208
void W_Info::SetMap(const char *name)
210
char *upper = UtilStrUpper(name);
212
map_name->value(upper);
217
void W_Info::SetNodes(const char *type)
219
node_type->value(type);
222
void W_Info::SetZoom(float zoom_mul)
226
/// if (0.99 < zoom_mul && zoom_mul < 1.01)
228
/// grid_size->value("1:1");
234
sprintf(buffer, "/ %1.3f", 1.0/zoom_mul);
238
sprintf(buffer, "x %1.3f", zoom_mul);
241
grid_size->value(buffer);
245
void W_Info::SetNodeIndex(int index)
249
sprintf(buffer, "%d", index);
251
ns_index->label("Node # ");
252
ns_index->value(buffer);
266
void W_Info::SetSubsectorIndex(int index)
270
sprintf(buffer, "%d", index);
272
ns_index->label("Subsec #");
273
ns_index->value(buffer);
287
void W_Info::SetCurBBox(const bbox_t *bbox)
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);
307
void W_Info::SetPartition(const node_c *part)
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);
327
void W_Info::SetMouse(double mx, double my)
329
if (mx < -32767.0 || mx > 32767.0 ||
330
my < -32767.0 || my > 32767.0)
332
mouse_x->value("off map");
333
mouse_y->value("off map");
341
sprintf(x_buffer, "%1.1f", mx);
342
sprintf(y_buffer, "%1.1f", my);
344
mouse_x->value(x_buffer);
345
mouse_y->value(y_buffer);
348
void W_Info::BeginSegList()
353
void W_Info::AddSeg(const seg_c *seg)
355
if (num_segs < SEG_LIST_MAX)
357
seg_indices[num_segs++] = seg->index;
361
void W_Info::EndSegList()
363
char buffer[SEG_LIST_MAX * 32];
368
for (int n = 0; n < num_segs; n++)
372
sprintf(num_buf, "%d", seg_indices[n]);
374
int line_len = strlen(line);
375
int num_len = strlen(num_buf);
378
if (line_len + 1 + num_len <= 19)
385
strcat(buffer, "\n");
387
line = buffer + strlen(buffer);
390
strcat(buffer, num_buf);
393
seg_list->value(buffer);