summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/GipfelWidget.H6
-rw-r--r--src/GipfelWidget.cxx26
-rw-r--r--src/gipfel.cxx20
3 files changed, 39 insertions, 13 deletions
diff --git a/src/GipfelWidget.H b/src/GipfelWidget.H
index 96c1f0d..61f3ed4 100644
--- a/src/GipfelWidget.H
+++ b/src/GipfelWidget.H
@@ -36,7 +36,7 @@ class GipfelWidget : public Fl_Widget {
Panorama *pan;
Fl_Menu_Button *mb;
char *img_file;
-
+ double track_width;
int handle(int event);
@@ -46,7 +46,7 @@ class GipfelWidget : public Fl_Widget {
void set_labels(Hills *v);
- int get_track_width(Hill *m);
+ int get_rel_track_width(Hill *m);
public:
GipfelWidget(int X,int Y,int W, int H);
@@ -99,6 +99,8 @@ class GipfelWidget : public Fl_Widget {
double get_view_height();
+ void set_track_width(double w);
+
Projection::Projection_t get_projection();
void set_projection(Projection::Projection_t p);
diff --git a/src/GipfelWidget.cxx b/src/GipfelWidget.cxx
index 32806a8..bfa61dd 100644
--- a/src/GipfelWidget.cxx
+++ b/src/GipfelWidget.cxx
@@ -66,6 +66,7 @@ GipfelWidget::GipfelWidget(int X,int Y,int W, int H): Fl_Widget(X, Y, W, H) {
m1 = NULL;
m2 = NULL;
img_file = NULL;
+ track_width = 500.0;
for (i=0; i<=3; i++) {
marker->add(new Hill(i * 10, 0));
@@ -343,20 +344,23 @@ GipfelWidget::draw() {
/* track */
if (track_points && track_points->get_num() > 0) {
int last_x, last_y, last_initialized = 0;
-
+
fl_color(FL_RED);
for (i=1; i<track_points->get_num(); i++) {
if (!(track_points->get(i)->flags & Hill::VISIBLE)) {
continue;
}
- fl_line_style(FL_SOLID, get_track_width(track_points->get(i)));
+ fl_line_style(FL_SOLID|FL_CAP_ROUND|FL_JOIN_ROUND,
+ get_rel_track_width(track_points->get(i)));
if (last_initialized) {
- fl_line(center_x + x() + last_x,
- center_y + y() + last_y,
- center_x + x() + track_points->get(i)->x,
- center_y + y() + track_points->get(i)->y);
+ fl_begin_line();
+ fl_vertex(center_x + x() + last_x, center_y + y() + last_y);
+ fl_vertex(center_x + x() + track_points->get(i)->x,
+ center_y + y() + track_points->get(i)->y);
+ fl_end_line();
}
+
last_x = track_points->get(i)->x;
last_y = track_points->get(i)->y;
last_initialized++;
@@ -662,10 +666,16 @@ GipfelWidget::update() {
}
int
-GipfelWidget::get_track_width(Hill *m) {
+GipfelWidget::get_rel_track_width(Hill *m) {
double dist = pan->get_real_distance(m);
- return MAX(10000.0 / dist, 1.0);
+ return MAX((pan->get_scale() * track_width) / (dist * 10.0), 1.0);
+}
+
+void
+GipfelWidget::set_track_width(double w) {
+ track_width = w;
+ redraw();
}
int
diff --git a/src/gipfel.cxx b/src/gipfel.cxx
index 01b1cd0..7bec5c6 100644
--- a/src/gipfel.cxx
+++ b/src/gipfel.cxx
@@ -55,7 +55,7 @@ char *data_file = DEFAULT_DATAFILE;
GipfelWidget *gipf = NULL;
Fl_Dial *s_center = NULL;
-Fl_Slider *s_nick = NULL, *s_scale = NULL, *s_tilt = NULL, *s_height_dist;
+Fl_Slider *s_nick, *s_scale, *s_tilt, *s_height_dist, *s_track_width;
Fl_Value_Input *i_view_lat, *i_view_long, *i_view_height;
Fl_Box *b_viewpoint;
Fl_Menu_Bar *mb;
@@ -135,6 +135,10 @@ void view_height_cb(Fl_Value_Input* o, void*) {
gipf->set_view_height(o->value());
}
+void track_width_cb(Fl_Value_Input* o, void*) {
+ gipf->set_track_width(o->value());
+}
+
void viewpoint_cb(Fl_Value_Input* o, void*) {
Hill *m = choose_hill(gipf->get_mountains(), "Choose Viewpoint");
if (m) {
@@ -254,6 +258,16 @@ create_control_window() {
s_height_dist->callback((Fl_Callback*)h_d_cb);
s_height_dist->align(FL_ALIGN_TOP);
+ s_track_width = new Fl_Value_Slider(235, 180, 160, 15, "Track Width");
+ s_track_width->type(1);
+ s_track_width->box(FL_THIN_DOWN_BOX);
+ s_track_width->labelsize(10);
+ s_track_width->step(1.0);
+ s_track_width->bounds(1.0, 2000.0);
+ s_track_width->slider(FL_UP_BOX);
+ s_track_width->callback((Fl_Callback*)track_width_cb);
+ s_track_width->align(FL_ALIGN_TOP);
+
// Viewpoint Stuff
b_viewpoint = new Fl_Box(FL_DOWN_BOX, 30, 255, 300, 80, "");
@@ -278,10 +292,10 @@ create_control_window() {
i_view_height->callback((Fl_Callback*)view_height_cb);
// Buttons
- Fl_Button *b = new Fl_Button(240, 180, 50, 15, "comp");
+ Fl_Button *b = new Fl_Button(240, 210, 50, 15, "comp");
b->color(FL_RED);
b->callback(comp_cb);
- Fl_Button *b1 = new Fl_Button(320, 180, 50, 15, "guess");
+ Fl_Button *b1 = new Fl_Button(320, 210, 50, 15, "guess");
b1->callback(guess_cb);
b1->color(FL_GREEN);