aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--profile.c49
-rw-r--r--profile.h2
-rw-r--r--qt-ui/profilegraphics.cpp57
-rw-r--r--qt-ui/profilegraphics.h3
4 files changed, 59 insertions, 52 deletions
diff --git a/profile.c b/profile.c
index 61bbd12ce..3905a029c 100644
--- a/profile.c
+++ b/profile.c
@@ -193,10 +193,11 @@ void remember_event(const char *eventname)
evn_used++;
}
-int setup_temperature_limits(struct graphics_context *gc, struct plot_info *pi)
+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;
@@ -461,53 +462,7 @@ static void plot_pp_gas_profile(struct graphics_context *gc, struct plot_info *p
-static void plot_single_temp_text(struct graphics_context *gc, int sec, int mkelvin)
-{
- double deg;
- const char *unit;
- static const text_render_options_t tro = {TEMP_TEXT_SIZE, TEMP_TEXT, LEFT, TOP};
-
- deg = get_temp_units(mkelvin, &unit);
-
- plot_text(gc, &tro, sec, mkelvin, "%.2g%s", deg, unit);
-}
-
-static void plot_temperature_text(struct graphics_context *gc, struct plot_info *pi)
-{
- int i;
- int last = -300, sec = 0;
- int last_temperature = 0, last_printed_temp = 0;
-
- if (!setup_temperature_limits(gc, pi))
- return;
-
- for (i = 0; i < pi->nr; i++) {
- struct plot_data *entry = pi->entry+i;
- int mkelvin = entry->temperature;
- sec = entry->sec;
- if (!mkelvin)
- continue;
- last_temperature = mkelvin;
- /* don't print a temperature
- * if it's been less than 5min and less than a 2K change OR
- * if it's been less than 2min OR if the change from the
- * last print is less than .4K (and therefore less than 1F */
- if (((sec < last + 300) && (abs(mkelvin - last_printed_temp) < 2000)) ||
- (sec < last + 120) ||
- (abs(mkelvin - last_printed_temp) < 400))
- continue;
- last = sec;
- plot_single_temp_text(gc,sec,mkelvin);
- last_printed_temp = mkelvin;
- }
- /* it would be nice to print the end temperature, if it's
- * different or if the last temperature print has been more
- * than a quarter of the dive back */
- if ((abs(last_temperature - last_printed_temp) > 500) ||
- ((double)last / (double)sec < 0.75))
- plot_single_temp_text(gc, sec, last_temperature);
-}
/* gets both the actual start and end pressure as well as the scaling factors */
diff --git a/profile.h b/profile.h
index 9389641d5..73c5152f9 100644
--- a/profile.h
+++ b/profile.h
@@ -38,7 +38,7 @@ struct plot_data {
void calculate_max_limits(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc);
struct plot_info *create_plot_info(struct dive *dive, struct divecomputer *dc, struct graphics_context *gc);
-int setup_temperature_limits(struct graphics_context *gc, struct plot_info *pi);
+int setup_temperature_limits(struct graphics_context *gc);
int get_cylinder_pressure_range(struct graphics_context *gc);
struct ev_select {
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 3baf2b008..53d943e09 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -242,10 +242,13 @@ void ProfileGraphicsView::plot(struct dive *dive)
/* Cylinder pressure plot */
plot_cylinder_pressure(dive, dc);
-#if 0
+
/* Text on top of all graphs.. */
- plot_temperature_text(gc, pi);
+ plot_temperature_text();
+
plot_depth_text(gc, pi);
+
+#if 0
plot_cylinder_pressure_text(gc, pi);
plot_deco_text(gc, pi);
#endif
@@ -289,6 +292,54 @@ void ProfileGraphicsView::plot(struct dive *dive)
#endif
}
+void ProfileGraphicsView::plot_temperature_text()
+{
+ int i;
+ int last = -300, sec = 0;
+ int last_temperature = 0, last_printed_temp = 0;
+ plot_info *pi = &gc.pi;
+
+ if (!setup_temperature_limits(&gc))
+ return;
+
+ for (i = 0; i < pi->nr; i++) {
+ struct plot_data *entry = pi->entry+i;
+ int mkelvin = entry->temperature;
+ sec = entry->sec;
+
+ if (!mkelvin)
+ continue;
+ last_temperature = mkelvin;
+ /* don't print a temperature
+ * if it's been less than 5min and less than a 2K change OR
+ * if it's been less than 2min OR if the change from the
+ * last print is less than .4K (and therefore less than 1F */
+ if (((sec < last + 300) && (abs(mkelvin - last_printed_temp) < 2000)) ||
+ (sec < last + 120) ||
+ (abs(mkelvin - last_printed_temp) < 400))
+ continue;
+ last = sec;
+
+ plot_single_temp_text(sec,mkelvin);
+ last_printed_temp = mkelvin;
+ }
+ /* it would be nice to print the end temperature, if it's
+ * different or if the last temperature print has been more
+ * than a quarter of the dive back */
+ if ((abs(last_temperature - last_printed_temp) > 500) ||
+ ((double)last / (double)sec < 0.75))
+ plot_single_temp_text(sec, last_temperature);
+}
+
+void ProfileGraphicsView::plot_single_temp_text(int sec, int mkelvin)
+{
+ double deg;
+ const char *unit;
+ static text_render_options_t tro = {TEMP_TEXT_SIZE, TEMP_TEXT, LEFT, TOP};
+ deg = get_temp_units(mkelvin, &unit);
+ plot_text(&tro, sec, mkelvin, QString("%1%2").arg(deg).arg(unit)); //"%.2g%s"
+}
+
void ProfileGraphicsView::plot_cylinder_pressure(struct dive *dive, struct divecomputer *dc)
{
int i;
@@ -716,7 +767,7 @@ void ProfileGraphicsView::plot_temperature_profile()
{
int last = 0;
- if (!setup_temperature_limits(&gc, &gc.pi))
+ if (!setup_temperature_limits(&gc))
return;
QPointF from;
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index 7f166574d..d6c30dda2 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -97,7 +97,8 @@ private:
void plot_one_event(struct event *event);
void plot_temperature_profile();
void plot_cylinder_pressure(struct dive *dive, struct divecomputer *dc);
-
+ void plot_temperature_text();
+ void plot_single_temp_text(int sec, int mkelvin);
QColor get_sac_color(int sac, int avg_sac);
QPen defaultPen;