summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre GRANDIN <pgrandin@users.noreply.github.com>2016-09-13 11:32:51 -0700
committerGitHub <noreply@github.com>2016-09-13 11:32:51 -0700
commitb7f66230027ffede782e16ca1cb83212a9c46656 (patch)
tree56b496c316130f159c886fb6a4653ada8f228166
parent0068b7b41576d2a3a88b4f4ff4bea86f6ed6300b (diff)
parent4629257a7d7e5d99022af74192bb01db170d33d0 (diff)
downloadnavit-b7f66230027ffede782e16ca1cb83212a9c46656.tar.gz
Merge pull request #115 from navit-gps/gui_internal_heightprofileR6778
Gui internal heightprofile
-rw-r--r--navit/gui/internal/gui_internal.c33
-rw-r--r--navit/gui/internal/gui_internal_command.c19
-rw-r--r--navit/navit_shipped.xml24
-rw-r--r--navit/xpm/gui_heightprofile.svg20
4 files changed, 61 insertions, 35 deletions
diff --git a/navit/gui/internal/gui_internal.c b/navit/gui/internal/gui_internal.c
index cf7db42a7..072c6feca 100644
--- a/navit/gui/internal/gui_internal.c
+++ b/navit/gui/internal/gui_internal.c
@@ -3118,12 +3118,14 @@ static struct gui_internal_widget_methods gui_internal_widget_methods = {
gui_internal_set_default_background,
};
-
-/*
- * @brief Displays Route information
+/**
+ * @brief finds the intersection point of 2 lines
+ *
+ * @param coord a1, a2, b1, b2 : coords of the start and
+ * end of the first and the second line
+ * @param coord res, will become the coords of the intersection if found
+ * @return : TRUE if intersection found, otherwise FALSE
*/
-/* FIXME where is the implementation? */
-
int
line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct coord *b2, struct coord *res)
{
@@ -3141,18 +3143,19 @@ line_intersection(struct coord* a1, struct coord *a2, struct coord * b1, struct
b = -b;
}
if (a < 0 || b < 0)
- return 0;
+ return FALSE;
if (a > n || b > n)
- return 0;
+ return FALSE;
if (n == 0) {
dbg(lvl_info,"a=%d b=%d n=%d\n", a, b, n);
dbg(lvl_info,"a1=0x%x,0x%x ad %d,%d\n", a1->x, a1->y, adx, ady);
dbg(lvl_info,"b1=0x%x,0x%x bd %d,%d\n", b1->x, b1->y, bdx, bdy);
- dbg_assert(n != 0);
+ dbg(lvl_info,"No intersection found, lines assumed parallel ?\n");
+ return FALSE;
}
res->x = a1->x + a * adx / n;
res->y = a1->y + a * ady / n;
- return 1;
+ return TRUE;
}
struct heightline *
@@ -3182,18 +3185,6 @@ item_get_heightline(struct item *item)
return ret;
}
-
-/*
- * @brief Displays Route Height Profile
- *
- * @li The name of the active vehicle
- * @param wm The button that was pressed.
- * @param v Unused
- */
-/* FIXME where is the implementation? */
-
-
-
/**
* @brief Called when the route is updated.
*/
diff --git a/navit/gui/internal/gui_internal_command.c b/navit/gui/internal/gui_internal_command.c
index 182671b35..21e299162 100644
--- a/navit/gui/internal/gui_internal_command.c
+++ b/navit/gui/internal/gui_internal_command.c
@@ -453,22 +453,14 @@ gui_internal_cmd2_setting_layout(struct gui_priv *this, char *function, struct a
* displays a heightprofile if a route is active and
* some heightinfo is provided by means of a map
*
- * the drawing is simplified by assuming straight
- * roads between the crossings of the route and the
- * heightlines.
- *
* the name of the file providing the heightlines must
* comply with *.heightlines.bin
*
- * todo : make it show a flat segment when using a tunnel
*/
static void
gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, struct attr **in, struct attr ***out, int *valid)
{
-
-
struct widget * menu, *box;
-
struct map * map=NULL;
struct map_rect * mr=NULL;
struct route * route;
@@ -511,6 +503,7 @@ gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, st
mr = NULL;
ms=navit_get_mapset(this->nav);
if (!first && ms) {
+ int heightmap_installed = FALSE;
msh=mapset_open(ms);
while ((map=mapset_next(msh, 1))) {
struct attr name_attr;
@@ -519,6 +512,7 @@ gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, st
if (strstr(name_attr.u.str,".heightlines.bin")){
dbg(lvl_info,"reading heightlines from map %s\n",name_attr.u.str);
mr=map_rect_new(map, &sel);
+ heightmap_installed = TRUE;
}
else {
dbg(lvl_debug,"ignoring map %s\n",name_attr.u.str);
@@ -539,6 +533,14 @@ gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, st
}
}
mapset_close(msh);
+ if (!heightmap_installed){
+ char *text;
+ struct widget *w;
+ text=g_strdup_printf("%s",_("please install a map *.heightlines.bin to provide elevationdata"));
+ gui_internal_widget_append(box, w=gui_internal_label_new(this, text));
+ w->flags=gravity_bottom_center|orientation_horizontal|flags_fill;
+ g_free(text);
+ }
}
}
map=NULL;
@@ -580,7 +582,6 @@ gui_internal_cmd2_route_height_profile(struct gui_priv *this, char *function, st
}
last=c;
}
-
}
}
if(mr)
diff --git a/navit/navit_shipped.xml b/navit/navit_shipped.xml
index 546d3a494..eb2191963 100644
--- a/navit/navit_shipped.xml
+++ b/navit/navit_shipped.xml
@@ -95,7 +95,7 @@ Navigation</text></img>
</a>
<a name='Route'><text>Route</text>
<img src='gui_actions' onclick='route_description()'><text>Description</text></img>
- <img src='gui_actions' onclick='route_height_profile()'><text>Height Profile</text></img>
+ <img src='gui_heightprofile' onclick='route_height_profile()'><text>Height Profile</text></img>
<img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='cursor_still' onclick='waypoints()'><text>Waypoints</text></img>
<img cond='navit.waypoints_flag &amp;&amp; (navit.route.route_status&amp;1)' src='gui_stop' onclick='navit.route_remove_last_waypoint()'><text>Drop last
Waypoint</text></img>
@@ -657,15 +657,29 @@ Waypoint</text></img>
<itemgra item_types="border_state" order="0-">
<polyline color="#808080" width="1"/>
</itemgra>
- <itemgra item_types="height_line_1" order="0-">
- <polyline color="#000000" width="4"/>
+ </layer>
+ <layer name="heightlines">
+ <itemgra item_types="height_line_1" order="7">
+ <polyline color="#000000" width="1"/>
</itemgra>
- <itemgra item_types="height_line_2" order="0-">
+ <itemgra item_types="height_line_1" order="8-">
+ <polyline color="#000000" width="3"/>
+ <text text_size="8"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="8">
+ <polyline color="#000000" width="1"/>
+ </itemgra>
+ <itemgra item_types="height_line_2" order="9-">
<polyline color="#000000" width="2"/>
+ <text text_size="8"/>
</itemgra>
- <itemgra item_types="height_line_3" order="0-">
+ <itemgra item_types="height_line_3" order="9-11">
<polyline color="#000000" width="1"/>
</itemgra>
+ <itemgra item_types="height_line_3" order="12-">
+ <polyline color="#000000" width="1"/>
+ <text text_size="8"/>
+ </itemgra>
</layer>
<layer name="streets">
<itemgra item_types="street_route" order="2">
diff --git a/navit/xpm/gui_heightprofile.svg b/navit/xpm/gui_heightprofile.svg
new file mode 100644
index 000000000..0d80b5c12
--- /dev/null
+++ b/navit/xpm/gui_heightprofile.svg
@@ -0,0 +1,20 @@
+<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
+ <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ for Navit -->
+ <defs>
+ <linearGradient y2="0%" x2="100%" y1="0%" x1="0%" id="grad1">
+ <stop stop-color="rgb(90,90,90)" offset="0%"/>
+ <stop stop-color="rgb(175,175,175)" offset="100%"/>
+ </linearGradient>
+ </defs>
+ <g>
+ <title>Layer 1</title>
+ <polygon transform="translate(0, -3)" id="svg_2" fill="url(#grad1)" points="10,165 30,165 60,80 75,120 85,120 115,20 160,180 190,180 190,190 10,190"/>
+ <line id="svg_3" fill="none" stroke="gainsboro" stroke-width="6" y2="165" x2="30" y1="165" x1="10"/>
+ <line id="svg_4" fill="none" stroke="gainsboro" stroke-width="6" y2="80" x2="60" y1="165" x1="30" stroke-linecap="round"/>
+ <line id="svg_5" fill="none" stroke="gainsboro" stroke-width="6" y2="120" x2="75" y1="80" x1="60" stroke-linecap="round"/>
+ <line id="svg_6" fill="none" stroke="gainsboro" stroke-width="6" y2="120" x2="85" y1="120" x1="75" stroke-linecap="round"/>
+ <line id="svg_7" fill="none" stroke="gainsboro" stroke-width="6" y2="20" x2="115" y1="120" x1="85" stroke-linecap="round"/>
+ <line id="svg_8" fill="none" stroke="gainsboro" stroke-width="6" y2="180" x2="160" y1="20" x1="115" stroke-linecap="round"/>
+ <line id="svg_9" fill="none" stroke="gainsboro" stroke-width="6" y2="180" x2="190" y1="180" x1="160"/>
+ </g>
+</svg>