summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-05-04 19:20:49 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-05-04 19:55:12 -0700
commit19048b98e59aedb4d03490095c646d337d47e38b (patch)
tree9ed5d6392fa1062ddbb4b68889034cdeea406ac2 /profile.c
parentfa82ba60798be8b5e20277527053199916888b16 (diff)
downloadsubsurface-19048b98e59aedb4d03490095c646d337d47e38b.tar.gz
Start plotting something.
The first plotting method was removed from profile.c to profilegraphics.cpp and some conversion ( almost 1 to 1 ) was made so that the code could work. Since the code is big - this commit has just a part of it working - it plots the grid. but already works for testing the resizing of the window and Zooming ( unimplemented ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c204
1 files changed, 0 insertions, 204 deletions
diff --git a/profile.c b/profile.c
index 3f413f4ed..be6efa1e6 100644
--- a/profile.c
+++ b/profile.c
@@ -58,11 +58,6 @@ struct plot_data {
#if USE_GTK_UI
-/* Scale to 0,0 -> maxx,maxy */
-#define SCALEX(gc,x) (((x)-gc->leftx)/(gc->rightx-gc->leftx)*gc->maxx)
-#define SCALEY(gc,y) (((y)-gc->topy)/(gc->bottomy-gc->topy)*gc->maxy)
-#define SCALE(gc,x,y) SCALEX(gc,x),SCALEY(gc,y)
-
/* keep the last used gc around so we can invert the SCALEX calculation in
* order to calculate a time value for an x coordinate */
static struct graphics_context last_gc;
@@ -611,205 +606,6 @@ static void plot_pp_gas_profile(struct graphics_context *gc, struct plot_info *p
}
}
-static void plot_depth_profile(struct graphics_context *gc, struct plot_info *pi)
-{
- int i, incr;
- cairo_t *cr = gc->cr;
- int sec, depth;
- struct plot_data *entry;
- int maxtime, maxdepth, marker, maxline;
- int increments[8] = { 10, 20, 30, 60, 5*60, 10*60, 15*60, 30*60 };
-
- /* Get plot scaling limits */
- maxtime = get_maxtime(pi);
- maxdepth = get_maxdepth(pi);
-
- gc->maxtime = maxtime;
-
- /* Time markers: at most every 10 seconds, but no more than 12 markers.
- * We start out with 10 seconds and increment up to 30 minutes,
- * depending on the dive time.
- * This allows for 6h dives - enough (I hope) for even the craziest
- * divers - but just in case, for those 8h depth-record-breaking dives,
- * we double the interval if this still doesn't get us to 12 or fewer
- * time markers */
- i = 0;
- while (maxtime / increments[i] > 12 && i < 7)
- i++;
- incr = increments[i];
- while (maxtime / incr > 12)
- incr *= 2;
-
- gc->leftx = 0; gc->rightx = maxtime;
- gc->topy = 0; gc->bottomy = 1.0;
-
- last_gc = *gc;
-
- set_source_rgba(gc, TIME_GRID);
- cairo_set_line_width_scaled(gc->cr, 2);
-
- for (i = incr; i < maxtime; i += incr) {
- move_to(gc, i, 0);
- line_to(gc, i, 1);
- }
- cairo_stroke(cr);
-
- /* now the text on the time markers */
- text_render_options_t tro = {DEPTH_TEXT_SIZE, TIME_TEXT, CENTER, TOP};
- if (maxtime < 600) {
- /* Be a bit more verbose with shorter dives */
- for (i = incr; i < maxtime; i += incr)
- plot_text(gc, &tro, i, 1, "%02d:%02d", i/60, i%60);
- } else {
- /* Only render the time on every second marker for normal dives */
- for (i = incr; i < maxtime; i += 2 * incr)
- plot_text(gc, &tro, i, 1, "%d", i/60);
- }
- /* Depth markers: every 30 ft or 10 m*/
- gc->leftx = 0; gc->rightx = 1.0;
- gc->topy = 0; gc->bottomy = maxdepth;
- switch (prefs.units.length) {
- case METERS: marker = 10000; break;
- case FEET: marker = 9144; break; /* 30 ft */
- }
- maxline = MAX(pi->maxdepth + marker, maxdepth * 2 / 3);
- set_source_rgba(gc, DEPTH_GRID);
- for (i = marker; i < maxline; i += marker) {
- move_to(gc, 0, i);
- line_to(gc, 1, i);
- }
- cairo_stroke(cr);
-
- gc->leftx = 0; gc->rightx = maxtime;
-
- /* Show mean depth */
- if (! gc->printer) {
- set_source_rgba(gc, MEAN_DEPTH);
- move_to(gc, 0, pi->meandepth);
- line_to(gc, pi->entry[pi->nr - 1].sec, pi->meandepth);
- cairo_stroke(cr);
- }
-
- /*
- * These are good for debugging text placement etc,
- * but not for actual display..
- */
- if (0) {
- plot_smoothed_profile(gc, pi);
- plot_minmax_profile(gc, pi);
- }
-
- /* Do the depth profile for the neat fill */
- gc->topy = 0; gc->bottomy = maxdepth;
-
- cairo_pattern_t *pat;
- pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
- pattern_add_color_stop_rgba (gc, pat, 1, DEPTH_BOTTOM);
- pattern_add_color_stop_rgba (gc, pat, 0, DEPTH_TOP);
-
- cairo_set_source(gc->cr, pat);
- cairo_pattern_destroy(pat);
- cairo_set_line_width_scaled(gc->cr, 2);
-
- entry = pi->entry;
- move_to(gc, 0, 0);
- for (i = 0; i < pi->nr; i++, entry++)
- line_to(gc, entry->sec, entry->depth);
-
- /* Show any ceiling we may have encountered */
- for (i = pi->nr - 1; i >= 0; i--, entry--) {
- if (entry->ndl) {
- /* non-zero NDL implies this is a safety stop, no ceiling */
- line_to(gc, entry->sec, 0);
- } else if (entry->stopdepth < entry->depth) {
- line_to(gc, entry->sec, entry->stopdepth);
- } else {
- line_to(gc, entry->sec, entry->depth);
- }
- }
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
-
- /* if the user wants the deco ceiling more visible, do that here (this
- * basically draws over the background that we had allowed to shine
- * through so far) */
- if (prefs.profile_red_ceiling) {
- pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
- pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW);
- pattern_add_color_stop_rgba (gc, pat, 1, CEILING_DEEP);
- cairo_set_source(gc->cr, pat);
- cairo_pattern_destroy(pat);
- entry = pi->entry;
- move_to(gc, 0, 0);
- for (i = 0; i < pi->nr; i++, entry++) {
- if (entry->ndl == 0 && entry->stopdepth) {
- if (entry->ndl == 0 && entry->stopdepth < entry->depth) {
- line_to(gc, entry->sec, entry->stopdepth);
- } else {
- line_to(gc, entry->sec, entry->depth);
- }
- } else {
- line_to(gc, entry->sec, 0);
- }
- }
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
- }
- /* finally, plot the calculated ceiling over all this */
- if (prefs.profile_calc_ceiling) {
- pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
- pattern_add_color_stop_rgba (gc, pat, 0, CALC_CEILING_SHALLOW);
- pattern_add_color_stop_rgba (gc, pat, 1, CALC_CEILING_DEEP);
- cairo_set_source(gc->cr, pat);
- cairo_pattern_destroy(pat);
- entry = pi->entry;
- move_to(gc, 0, 0);
- for (i = 0; i < pi->nr; i++, entry++) {
- if (entry->ceiling)
- line_to(gc, entry->sec, entry->ceiling);
- else
- line_to(gc, entry->sec, 0);
- }
- line_to(gc, (entry-1)->sec, 0); /* make sure we end at 0 */
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
- }
- /* next show where we have been bad and crossed the dc's ceiling */
- pat = cairo_pattern_create_linear (0.0, 0.0, 0.0, 256.0 * plot_scale);
- pattern_add_color_stop_rgba (gc, pat, 0, CEILING_SHALLOW);
- pattern_add_color_stop_rgba (gc, pat, 1, CEILING_DEEP);
- cairo_set_source(gc->cr, pat);
- cairo_pattern_destroy(pat);
- entry = pi->entry;
- move_to(gc, 0, 0);
- for (i = 0; i < pi->nr; i++, entry++)
- line_to(gc, entry->sec, entry->depth);
-
- for (i = pi->nr - 1; i >= 0; i--, entry--) {
- if (entry->ndl == 0 && entry->stopdepth > entry->depth) {
- line_to(gc, entry->sec, entry->stopdepth);
- } else {
- line_to(gc, entry->sec, entry->depth);
- }
- }
- cairo_close_path(gc->cr);
- cairo_fill(gc->cr);
-
- /* Now do it again for the velocity colors */
- entry = pi->entry;
- for (i = 1; i < pi->nr; i++) {
- entry++;
- sec = entry->sec;
- /* we want to draw the segments in different colors
- * representing the vertical velocity, so we need to
- * chop this into short segments */
- depth = entry->depth;
- set_source_rgba(gc, VELOCITY_COLORS_START_IDX + entry->velocity);
- move_to(gc, entry[-1].sec, entry[-1].depth);
- line_to(gc, sec, depth);
- cairo_stroke(cr);
- }
-}
static int setup_temperature_limits(struct graphics_context *gc, struct plot_info *pi)
{