diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-03-07 13:31:47 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-03-07 08:56:06 -0800 |
commit | 00c97e710f0090b3a2a8d5fe5b92e5ac0207a4b9 (patch) | |
tree | 7643d93d7cfa5ed3012e71ba2c2269f2c32c851c | |
parent | 8f43ad8100c779b802586394f08d2572911d4d15 (diff) | |
download | subsurface-00c97e710f0090b3a2a8d5fe5b92e5ac0207a4b9.tar.gz |
Remove a Lot of Dead Code.
This is just removal of dead code from the old profile, probably there's
still a bit more to remove, but this is a very good cleanup already.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | display.h | 13 | ||||
-rw-r--r-- | profile.c | 252 | ||||
-rw-r--r-- | profile.h | 42 | ||||
-rw-r--r-- | qt-ui/printlayout.cpp | 1 | ||||
-rw-r--r-- | qt-ui/profile/diveprofileitem.cpp | 1 | ||||
-rw-r--r-- | qt-ui/profile/divetooltipitem.cpp | 17 | ||||
-rw-r--r-- | qt-ui/profile/divetooltipitem.h | 1 |
7 files changed, 1 insertions, 326 deletions
@@ -27,25 +27,12 @@ struct plot_info { struct plot_data *entry; }; -/* - * handy datastructure to keep all of our scaling data in one place - */ -struct graphics_context { - int printer; - double maxx, maxy; - double leftx, rightx; - double topy, bottomy; - unsigned int maxtime; - struct plot_info pi; -}; - typedef enum { SC_SCREEN, SC_PRINT } scale_mode_t; extern struct divecomputer *select_dc(struct divecomputer *main); -extern void get_plot_details(struct graphics_context *gc, int time, struct membuffer *mb); struct options { enum { @@ -19,7 +19,7 @@ int selected_dive = -1; /* careful: 0 is a valid value */ char dc_number = 0; -static struct plot_data *last_pi_entry = NULL, *last_pi_entry_new = NULL; +static struct plot_data *last_pi_entry_new = NULL; #ifdef DEBUG_PI /* debugging tool - not normally used */ @@ -141,69 +141,6 @@ void remember_event(const char *eventname) evn_used++; } -int setup_temperature_limits(struct graphics_context *gc) -{ - int maxtime, mintemp, maxtemp, delta; - - struct plot_info *pi = &gc->pi; - /* Get plot scaling limits */ - maxtime = get_maxtime(pi); - mintemp = pi->mintemp; - maxtemp = pi->maxtemp; - - gc->leftx = 0; - gc->rightx = maxtime; - /* Show temperatures in roughly the lower third, but make sure the scale - is at least somewhat reasonable */ - delta = maxtemp - mintemp; - if (delta < 3000) /* less than 3K in fluctuation */ - delta = 3000; - gc->topy = maxtemp + delta * 2; - - if (PP_GRAPHS_ENABLED) - gc->bottomy = mintemp - delta * 2; - else - gc->bottomy = mintemp - delta / 3; - - pi->endtempcoord = SCALEY(gc, pi->mintemp); - return maxtemp && maxtemp >= mintemp; -} - -void setup_pp_limits(struct graphics_context *gc) -{ - int maxdepth; - - gc->leftx = 0; - gc->rightx = get_maxtime(&gc->pi); - - /* the maxdepth already includes extra vertical space - and if - * we use 1.5 times the corresponding pressure as maximum partial - * pressure the graph seems to look fine*/ - maxdepth = get_maxdepth(&gc->pi); - gc->topy = 1.5 * (maxdepth + 10000) / 10000.0 * SURFACE_PRESSURE / 1000; - gc->bottomy = -gc->topy / 20; -} - -int get_cylinder_pressure_range(struct graphics_context *gc) -{ - gc->leftx = 0; - gc->rightx = get_maxtime(&gc->pi); - - if (PP_GRAPHS_ENABLED) - gc->bottomy = -gc->pi.maxpressure * 0.75; - else - gc->bottomy = 0; - gc->topy = gc->pi.maxpressure * 1.5; - if (!gc->pi.maxpressure) - return false; - - while (gc->pi.endtempcoord <= SCALEY(gc, gc->pi.minpressure - (gc->topy) * 0.1)) - gc->bottomy -= gc->topy * 0.1 * gc->maxy / abs(gc->maxy); - - return true; -} - - /* Get local sac-rate (in ml/min) between entry1 and entry2 */ static int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, struct dive *dive) { @@ -804,72 +741,6 @@ struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer return pi; } -void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc) -{ - struct plot_info *pi; - int maxdepth; - int maxtime = 0; - int maxpressure = 0, minpressure = INT_MAX; - int mintemp, maxtemp; - int cyl; - - /* The plot-info is embedded in the graphics context */ - pi = &gc->pi; - memset(pi, 0, sizeof(*pi)); - - maxdepth = dive->maxdepth.mm; - mintemp = dive->mintemp.mkelvin; - maxtemp = dive->maxtemp.mkelvin; - - /* Get the per-cylinder maximum pressure if they are manual */ - for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { - unsigned int mbar = dive->cylinder[cyl].start.mbar; - if (mbar > maxpressure) - maxpressure = mbar; - } - - /* Then do all the samples from all the dive computers */ - do { - int i = dc->samples; - int lastdepth = 0; - struct sample *s = dc->sample; - - while (--i >= 0) { - int depth = s->depth.mm; - int pressure = s->cylinderpressure.mbar; - int temperature = s->temperature.mkelvin; - - if (!mintemp && temperature < mintemp) - mintemp = temperature; - if (temperature > maxtemp) - maxtemp = temperature; - - if (pressure && pressure < minpressure) - minpressure = pressure; - if (pressure > maxpressure) - maxpressure = pressure; - - if (depth > maxdepth) - maxdepth = s->depth.mm; - if ((depth > SURFACE_THRESHOLD || lastdepth > SURFACE_THRESHOLD) && - s->time.seconds > maxtime) - maxtime = s->time.seconds; - lastdepth = depth; - s++; - } - } while ((dc = dc->next) != NULL); - - if (minpressure > maxpressure) - minpressure = 0; - - pi->maxdepth = maxdepth; - pi->maxtime = maxtime; - pi->maxpressure = maxpressure; - pi->minpressure = minpressure; - pi->mintemp = mintemp; - pi->maxtemp = maxtemp; -} - /* copy the previous entry (we know this exists), update time and depth * and zero out the sensor pressure (since this is a synthetic entry) * increment the entry pointer and the count of synthetic entries. */ @@ -1246,68 +1117,6 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru #endif } -static void calculate_gas_information(struct dive *dive, struct plot_info *pi) -{ - int i; - double amb_pressure; - - for (i = 1; i < pi->nr; i++) { - int fo2, fhe; - struct plot_data *entry = pi->entry + i; - int cylinderindex = entry->cylinderindex; - - amb_pressure = depth_to_mbar(entry->depth, dive) / 1000.0; - fo2 = get_o2(&dive->cylinder[cylinderindex].gasmix); - fhe = get_he(&dive->cylinder[cylinderindex].gasmix); - double ratio = (double)fhe / (1000.0 - fo2); - - if (entry->po2) { - /* we have an O2 partial pressure in the sample - so this - * is likely a CC dive... use that instead of the value - * from the cylinder info */ - double po2 = entry->po2 > amb_pressure ? amb_pressure : entry->po2; - entry->po2 = po2; - entry->phe = (amb_pressure - po2) * ratio; - entry->pn2 = amb_pressure - po2 - entry->phe; - } else { - entry->po2 = fo2 / 1000.0 * amb_pressure; - entry->phe = fhe / 1000.0 * amb_pressure; - entry->pn2 = (1000 - fo2 - fhe) / 1000.0 * amb_pressure; - } - - /* Calculate MOD, EAD, END and EADD based on partial pressures calculated before - * so there is no difference in calculating between OC and CC - * EAD takes O2 + N2 (air) into account - * END just uses N2 */ - entry->mod = (prefs.mod_ppO2 / fo2 * 1000 - 1) * 10000; - entry->ead = (entry->depth + 10000) * - (entry->po2 + (amb_pressure - entry->po2) * (1 - ratio)) / amb_pressure - 10000; - entry->end = (entry->depth + 10000) * - (amb_pressure - entry->po2) * (1 - ratio) / amb_pressure / N2_IN_AIR * 1000 - 10000; - entry->eadd = (entry->depth + 10000) * - (entry->po2 / amb_pressure * O2_DENSITY + entry->pn2 / amb_pressure * - N2_DENSITY + - entry->phe / amb_pressure * HE_DENSITY) / - (O2_IN_AIR * O2_DENSITY + N2_IN_AIR * N2_DENSITY) * 1000 - 10000; - if (entry->mod < 0) - entry->mod = 0; - if (entry->ead < 0) - entry->ead = 0; - if (entry->end < 0) - entry->end = 0; - if (entry->eadd < 0) - entry->eadd = 0; - - if (entry->po2 > pi->maxpp && prefs.pp_graphs.po2) - pi->maxpp = entry->po2; - if (entry->phe > pi->maxpp && prefs.pp_graphs.phe) - pi->maxpp = entry->phe; - if (entry->pn2 > pi->maxpp && prefs.pp_graphs.pn2) - pi->maxpp = entry->pn2; - } -} - - static void calculate_gas_information_new(struct dive *dive, struct plot_info *pi) { int i; @@ -1368,50 +1177,6 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p * sides, so that you can do end-points without having to worry * about it. */ -struct plot_info *create_plot_info(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc, bool print_mode) -{ - struct plot_info *pi; - - /* The plot-info is embedded in the graphics context */ - pi = &gc->pi; - - /* reset deco information to start the calculation */ - if (prefs.profile_calc_ceiling) - init_decompression(dive); - - /* Create the new plot data */ - if (last_pi_entry) - free((void *)last_pi_entry); - last_pi_entry = populate_plot_entries(dive, dc, pi); - - /* Populate the gas index from the gas change events */ - check_gas_change_events(dive, dc, pi); - - /* Try to populate our gas pressure knowledge */ - setup_gas_sensor_pressure(dive, dc, pi); - - /* .. calculate missing pressure entries */ - populate_pressure_information(dive, dc, pi); - - /* Calculate sac */ - calculate_sac(dive, pi); - - /* Then, calculate deco information */ - if (prefs.profile_calc_ceiling) - calculate_deco_information(dive, dc, pi, print_mode); - - /* And finaly calculate gas partial pressures */ - calculate_gas_information(dive, pi); - - pi->meandepth = dive->dc.meandepth.mm; - -#ifdef DEBUG_PI - /* awesome for debugging - not useful otherwise */ - dump_pi(pi); -#endif - return analyze_plot_info(pi); -} - void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi) { init_decompression(dive); @@ -1558,21 +1323,6 @@ static void plot_string(struct plot_data *entry, struct membuffer *b, bool has_n strip_mb(b); } -void get_plot_details(struct graphics_context *gc, int time, struct membuffer *mb) -{ - struct plot_info *pi = &gc->pi; - struct plot_data *entry = NULL; - int i; - - for (i = 0; i < pi->nr; i++) { - entry = pi->entry + i; - if (entry->sec >= time) - break; - } - if (entry) - plot_string(entry, mb, pi->has_ndl); -} - void get_plot_details_new(struct plot_info *pi, int time, struct membuffer *mb) { struct plot_data *entry = NULL; @@ -15,7 +15,6 @@ typedef enum { struct membuffer; struct divecomputer; -struct graphics_context; struct plot_info; struct plot_data { unsigned int in_deco : 1; @@ -52,12 +51,7 @@ struct plot_data { int heartbeat; int bearing; }; -//TODO: remove the calculatE_max_limits as soon as the new profile is done. -void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc); struct plot_info calculate_max_limits_new(struct dive *dive, struct divecomputer *dc); -struct plot_info *create_plot_info(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc, bool print_mode); -int setup_temperature_limits(struct graphics_context *gc); -int get_cylinder_pressure_range(struct graphics_context *gc); void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int bufsize, int sum); struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *dc, struct plot_info *pi); struct plot_info *analyze_plot_info(struct plot_info *pi); @@ -85,44 +79,8 @@ int get_maxtime(struct plot_info *pi); * partial pressure graphs */ int get_maxdepth(struct plot_info *pi); -void setup_pp_limits(struct graphics_context *gc); -#define ALIGN_LEFT 1 -#define ALIGN_RIGHT 2 -#define INVISIBLE 4 -#define UNSORTABLE 8 -#define EDITABLE 16 - -#ifndef TEXT_SCALE -#define TEXT_SCALE 1.0 -#endif - -#define DEPTH_TEXT_SIZE (12 * TEXT_SCALE) -#define PRESSURE_TEXT_SIZE (12 * TEXT_SCALE) -#define DC_TEXT_SIZE (12 * TEXT_SCALE) -#define PP_TEXT_SIZE (12 * TEXT_SCALE) -#define TEMP_TEXT_SIZE (12 * TEXT_SCALE) - -#define TEMP_TEXT_SCALE 0.8 -#define HR_TEXT_CALE 0.7 -#define RIGHT (-1.0) -#define CENTER (-0.5) -#define LEFT (0.0) - -#define LINE_DOWN (1) -#define TOP (0) -#define MIDDLE (-0.5) -#define BOTTOM (-1) - -#define SCALEXGC(x) (((x) - gc.leftx) / (gc.rightx - gc.leftx) * gc.maxx) -#define SCALEYGC(y) (((y) - gc.topy) / (gc.bottomy - gc.topy) * gc.maxy) -#define SCALEGC(x, y) SCALEXGC(x), SCALEYGC(y) - -#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) - #define SENSOR_PR 0 #define INTERPOLATED_PR 1 #define SENSOR_PRESSURE(_entry) (_entry)->pressure[SENSOR_PR] diff --git a/qt-ui/printlayout.cpp b/qt-ui/printlayout.cpp index b84f2ecea..64762cb2c 100644 --- a/qt-ui/printlayout.cpp +++ b/qt-ui/printlayout.cpp @@ -6,7 +6,6 @@ #include <QTableView> #include <QHeaderView> #include "mainwindow.h" -#include "profilegraphics.h" #include "../dive.h" #include "../display.h" #include "printdialog.h" diff --git a/qt-ui/profile/diveprofileitem.cpp b/qt-ui/profile/diveprofileitem.cpp index 77db58eca..454fab0c9 100644 --- a/qt-ui/profile/diveprofileitem.cpp +++ b/qt-ui/profile/diveprofileitem.cpp @@ -5,7 +5,6 @@ #include "divetextitem.h" #include "profile.h" #include "dive.h" -#include "profilegraphics.h" #include "preferences.h" #include "helpers.h" diff --git a/qt-ui/profile/divetooltipitem.cpp b/qt-ui/profile/divetooltipitem.cpp index 0442f0793..c11266a5a 100644 --- a/qt-ui/profile/divetooltipitem.cpp +++ b/qt-ui/profile/divetooltipitem.cpp @@ -37,23 +37,6 @@ void ToolTipItem::addToolTip(const QString &toolTip, const QIcon &icon) expand(); } -void ToolTipItem::refresh(struct graphics_context *gc, QPointF pos) -{ - clear(); - int time = (pos.x() * gc->maxtime) / gc->maxx; - struct membuffer mb = { 0 }; - - get_plot_details(gc, time, &mb); - addToolTip(QString::fromUtf8(mb.buffer, mb.len)); - free_buffer(&mb); - - QList<QGraphicsItem *> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform()); - Q_FOREACH(QGraphicsItem * item, items) { - if (!item->toolTip().isEmpty()) - addToolTip(item->toolTip()); - } -} - void ToolTipItem::clear() { Q_FOREACH(ToolTip t, toolTips) { diff --git a/qt-ui/profile/divetooltipitem.h b/qt-ui/profile/divetooltipitem.h index 566b21770..1f84d0664 100644 --- a/qt-ui/profile/divetooltipitem.h +++ b/qt-ui/profile/divetooltipitem.h @@ -41,7 +41,6 @@ public: void expand(); void clear(); void addToolTip(const QString &toolTip, const QIcon &icon = QIcon()); - void refresh(struct graphics_context *gc, QPointF pos); void refresh(const QPointF &pos); bool isExpanded() const; void persistPos(); |