summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <johannes.hofmann@gmx.de>2005-05-05 09:02:07 +0000
committerJohannes Hofmann <johannes.hofmann@gmx.de>2005-05-05 09:02:07 +0000
commit44cc474d39e0cb385fb105f99117f8b9776aa9f0 (patch)
tree263141904e2ab3d0661a8bec91757d7a0b79567b /src
parent02322687f219c6b32d8c271a928c11007ec8b49c (diff)
improve label rendering
improve label rendering
Diffstat (limited to 'src')
-rw-r--r--src/GipfelWidget.cxx14
-rw-r--r--src/Hill.cxx14
-rw-r--r--src/Makefile2
-rw-r--r--src/Panorama.cxx9
-rw-r--r--src/gipfel.cxx4
5 files changed, 26 insertions, 17 deletions
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 49562cf..5710ad0 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: GipfelWidget.cxx,v 1.18 2005/05/03 21:36:39 hofmann Exp $"
+// "$Id: GipfelWidget.cxx,v 1.19 2005/05/05 11:02:07 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -68,7 +68,7 @@ GipfelWidget::load_image(const char *file) {
if (img == NULL) {
return 1;
}
-
+
w(img->w());
h(img->h());
@@ -135,6 +135,12 @@ GipfelWidget::draw() {
fl_pop_clip();
}
+
+static int
+overlap(int m1, int n1, int m2, int n2) {
+ return m1 <= n2 && n1 >= m2;
+}
+
void
GipfelWidget::set_labels(Mountains *v) {
int i, j, width, height;
@@ -146,14 +152,14 @@ GipfelWidget::set_labels(Mountains *v) {
m = v->get(i);
fl_measure(m->name, width, height);
-
m->label_x = m->x + width;
m->label_y = m->y;
for (j=0; j<v->get_num() && j < i; j++) {
n = v->get(j);
- if (n->label_x >= m->x && n->label_y >= m->label_y - 1 && n->label_y <= m->label_y + height + 1) {
+ if (overlap(m->x, m->label_x, n->x, n->label_x) &&
+ overlap(m->label_y - height, m->label_y, n->label_y - height, n->label_y)) {
m->label_y = n->label_y - height - 1;
}
}
diff --git a/src/Hill.cxx b/src/Hill.cxx
index 443e639..88df3b3 100644
--- a/src/Hill.cxx
+++ b/src/Hill.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Hill.cxx,v 1.8 2005/05/03 21:36:39 hofmann Exp $"
+// "$Id: Hill.cxx,v 1.9 2005/05/05 11:02:07 hofmann Exp $"
//
// PSEditWidget routines.
//
@@ -57,7 +57,7 @@ Mountain::~Mountain() {
Mountains::Mountains() {
num = 0;
cap = 100;
- m = (Mountain **) malloc(cap * sizeof(class Mountain *));
+ m = (Mountain **) malloc(cap * sizeof(Mountain *));
}
Mountains::~Mountains() {
@@ -71,7 +71,7 @@ void
Mountains::add(Mountain *m1) {
if (num >= cap) {
cap = cap?cap * 2:100;
- m = (Mountain **) realloc(m, cap * sizeof(class Mountain *));
+ m = (Mountain **) realloc(m, cap * sizeof(Mountain *));
}
m[num++] = m1;
@@ -80,9 +80,9 @@ Mountains::add(Mountain *m1) {
static int
comp_mountains(const void *n1, const void *n2) {
- Mountain *m1 = (Mountain *)n1;
- Mountain *m2 = (Mountain *)n2;
-
+ Mountain *m1 = *(Mountain **)n1;
+ Mountain *m2 = *(Mountain **)n2;
+
if (m1 && m2) {
if (m1->alph < m2->alph) {
return 1;
@@ -102,7 +102,7 @@ Mountains::sort() {
return;
}
- qsort(m, num, sizeof(class Mountain *), comp_mountains);
+ qsort(m, num, sizeof(Mountain *), comp_mountains);
}
void
diff --git a/src/Makefile b/src/Makefile
index 7373740..40a0454 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,7 +1,7 @@
CC=gcc
CPP=c++
CFLAGS=-g -I/usr/X11R6/include
-CXXFLAGS=-g -I/usr/X11R6/include -I/usr/local/include -fno-stack-protector -O3
+CXXFLAGS=-g -I/usr/X11R6/include -I/usr/local/include -fno-stack-protector
LDFLAGS=-g -fno-stack-protector
OBJECTS=flmountains.o GipfelWidget.o Mountain.o Panorama.o
diff --git a/src/Panorama.cxx b/src/Panorama.cxx
index 7bc23e8..04b63fe 100644
--- a/src/Panorama.cxx
+++ b/src/Panorama.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: Panorama.cxx,v 1.25 2005/05/03 20:48:37 hofmann Exp $"
+// "$Id: Panorama.cxx,v 1.26 2005/05/05 11:02:07 hofmann Exp $"
//
// Panorama routines.
//
@@ -110,6 +110,7 @@ Panorama::load_file(const char *name) {
fclose(fp);
update_angles();
+
return 0;
}
@@ -121,6 +122,7 @@ Panorama::set_viewpoint(const char *name) {
}
update_angles();
+
return 0;
}
@@ -413,7 +415,9 @@ Panorama::update_angles() {
m->a_nick = nick(m->dist, m->height);
}
}
-
+
+ mountains->sort();
+
update_visible_mountains();
}
@@ -444,7 +448,6 @@ Panorama::update_visible_mountains() {
}
}
- visible_mountains->sort();
update_coordinates();
}
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index 4539913..2b28f1e 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: gipfel.cxx,v 1.15 2005/04/30 21:18:43 hofmann Exp $"
+// "$Id: gipfel.cxx,v 1.16 2005/05/05 11:02:07 hofmann Exp $"
//
// flpsed program.
//
@@ -198,7 +198,7 @@ int main(int argc, char** argv) {
r->box(FL_THIN_DOWN_BOX);
r->labelsize(10);
r->step(-0.005);
- r->bounds(0.2, 0.02);
+ r->bounds(0.2, 0.01);
r->slider(FL_UP_BOX);
r->callback((Fl_Callback*)h_d_cb);
r->align(FL_ALIGN_LEFT);