mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:53:23 +00:00
Plotting deco text.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e62eb58ab5
commit
25d65ab97d
4 changed files with 159 additions and 126 deletions
134
profile.c
134
profile.c
|
@ -220,6 +220,22 @@ int setup_temperature_limits(struct graphics_context *gc)
|
|||
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;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
static void plot_smoothed_profile(struct graphics_context *gc, struct plot_info *pi)
|
||||
|
@ -290,21 +306,6 @@ static void plot_depth_scale(struct graphics_context *gc, struct plot_info *pi)
|
|||
}
|
||||
}
|
||||
|
||||
static void setup_pp_limits(struct graphics_context *gc, struct plot_info *pi)
|
||||
{
|
||||
int maxdepth;
|
||||
|
||||
gc->leftx = 0;
|
||||
gc->rightx = get_maxtime(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(pi);
|
||||
gc->topy = 1.5 * (maxdepth + 10000) / 10000.0 * SURFACE_PRESSURE / 1000;
|
||||
gc->bottomy = -gc->topy / 20;
|
||||
}
|
||||
|
||||
static void plot_pp_text(struct graphics_context *gc, struct plot_info *pi)
|
||||
{
|
||||
double pp, dpp, m;
|
||||
|
@ -324,95 +325,6 @@ static void plot_pp_text(struct graphics_context *gc, struct plot_info *pi)
|
|||
}
|
||||
}
|
||||
|
||||
static void plot_pp_gas_profile(struct graphics_context *gc, struct plot_info *pi)
|
||||
{
|
||||
int i;
|
||||
struct plot_data *entry;
|
||||
|
||||
setup_pp_limits(gc, pi);
|
||||
|
||||
if (prefs.pp_graphs.pn2) {
|
||||
set_source_rgba(gc, PN2);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->pn2);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->pn2 < prefs.pp_graphs.pn2_threshold)
|
||||
line_to(gc, entry->sec, entry->pn2);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->pn2);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
|
||||
set_source_rgba(gc, PN2_ALERT);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->pn2);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->pn2 >= prefs.pp_graphs.pn2_threshold)
|
||||
line_to(gc, entry->sec, entry->pn2);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->pn2);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
}
|
||||
if (prefs.pp_graphs.phe) {
|
||||
set_source_rgba(gc, PHE);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->phe);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->phe < prefs.pp_graphs.phe_threshold)
|
||||
line_to(gc, entry->sec, entry->phe);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->phe);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
|
||||
set_source_rgba(gc, PHE_ALERT);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->phe);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->phe >= prefs.pp_graphs.phe_threshold)
|
||||
line_to(gc, entry->sec, entry->phe);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->phe);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
}
|
||||
if (prefs.pp_graphs.po2) {
|
||||
set_source_rgba(gc, PO2);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->po2);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->po2 < prefs.pp_graphs.po2_threshold)
|
||||
line_to(gc, entry->sec, entry->po2);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->po2);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
|
||||
set_source_rgba(gc, PO2_ALERT);
|
||||
entry = pi->entry;
|
||||
move_to(gc, entry->sec, entry->po2);
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->po2 >= prefs.pp_graphs.po2_threshold)
|
||||
line_to(gc, entry->sec, entry->po2);
|
||||
else
|
||||
move_to(gc, entry->sec, entry->po2);
|
||||
}
|
||||
cairo_stroke(gc->cr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* gets both the actual start and end pressure as well as the scaling factors */
|
||||
|
||||
#endif /* USE_GTK_UI */
|
||||
|
@ -468,20 +380,6 @@ int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, struct div
|
|||
return airuse / atm * 60 / duration;
|
||||
}
|
||||
|
||||
#if USE_GTK_UI
|
||||
|
||||
static void plot_deco_text(struct graphics_context *gc, struct plot_info *pi)
|
||||
{
|
||||
if (prefs.profile_calc_ceiling) {
|
||||
float x = gc->leftx + (gc->rightx - gc->leftx) / 2;
|
||||
float y = gc->topy = 1.0;
|
||||
text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, CENTER, -0.2};
|
||||
gc->bottomy = 0.0;
|
||||
plot_text(gc, &tro, x, y, "GF %.0f/%.0f", prefs.gflow * 100, prefs.gfhigh * 100);
|
||||
}
|
||||
}
|
||||
#endif /* USE_GTK_UI */
|
||||
|
||||
static void analyze_plot_info_minmax_minute(struct plot_data *entry, struct plot_data *first, struct plot_data *last, int index)
|
||||
{
|
||||
struct plot_data *p = entry;
|
||||
|
|
|
@ -63,6 +63,8 @@ int get_maxdepth(struct plot_info *pi);
|
|||
|
||||
int get_local_sac(struct plot_data *entry1, struct plot_data *entry2, struct dive *dive);
|
||||
|
||||
void setup_pp_limits(struct graphics_context *gc);
|
||||
|
||||
|
||||
#define ALIGN_LEFT 1
|
||||
#define ALIGN_RIGHT 2
|
||||
|
|
|
@ -249,9 +249,9 @@ void ProfileGraphicsView::plot(struct dive *dive)
|
|||
plot_depth_text();
|
||||
|
||||
plot_cylinder_pressure_text();
|
||||
#if 0
|
||||
plot_deco_text(gc, pi);
|
||||
#endif
|
||||
|
||||
plot_deco_text();
|
||||
|
||||
/* Bounding box */
|
||||
QColor color = profile_color[TIME_GRID].at(0);
|
||||
QPen pen = QPen(color);
|
||||
|
@ -269,12 +269,14 @@ void ProfileGraphicsView::plot(struct dive *dive)
|
|||
text_render_options_t computer = {DC_TEXT_SIZE, TIME_TEXT, LEFT, MIDDLE};
|
||||
plot_text(&computer, gc.leftx, gc.bottomy, nickname);
|
||||
}
|
||||
#if 0
|
||||
if (PP_GRAPHS_ENABLED) {
|
||||
plot_pp_gas_profile(gc, pi);
|
||||
plot_pp_text(gc, pi);
|
||||
}
|
||||
|
||||
|
||||
//if (PP_GRAPHS_ENABLED) {
|
||||
plot_pp_gas_profile();
|
||||
// plot_pp_text(gc, pi);
|
||||
//}
|
||||
|
||||
#if 0
|
||||
/* now shift the translation back by half the margin;
|
||||
* this way we can draw the vertical scales on both sides */
|
||||
cairo_translate(gc->cr, -drawing_area->x / 2.0, 0);
|
||||
|
@ -292,6 +294,135 @@ void ProfileGraphicsView::plot(struct dive *dive)
|
|||
#endif
|
||||
}
|
||||
|
||||
void ProfileGraphicsView::plot_pp_gas_profile()
|
||||
{
|
||||
int i;
|
||||
struct plot_data *entry;
|
||||
struct plot_info *pi = &gc.pi;
|
||||
|
||||
setup_pp_limits(&gc);
|
||||
QColor c;
|
||||
QPointF from, to;
|
||||
//if (prefs.pp_graphs.pn2) {
|
||||
c = profile_color[PN2].first();
|
||||
entry = pi->entry;
|
||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->pn2 < prefs.pp_graphs.pn2_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
}
|
||||
}
|
||||
|
||||
c = profile_color[PN2_ALERT].first();
|
||||
entry = pi->entry;
|
||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->pn2 >= prefs.pp_graphs.pn2_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->pn2));
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
//if (prefs.pp_graphs.phe) {
|
||||
c = profile_color[PHE].first();
|
||||
entry = pi->entry;
|
||||
|
||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->phe < prefs.pp_graphs.phe_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
}
|
||||
}
|
||||
|
||||
c = profile_color[PHE_ALERT].first();
|
||||
entry = pi->entry;
|
||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->phe >= prefs.pp_graphs.phe_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->phe));
|
||||
}
|
||||
}
|
||||
//}
|
||||
//if (prefs.pp_graphs.po2) {
|
||||
c = profile_color[PO2].first();
|
||||
entry = pi->entry;
|
||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->po2 < prefs.pp_graphs.po2_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
}
|
||||
}
|
||||
|
||||
c = profile_color[PO2_ALERT].first();
|
||||
entry = pi->entry;
|
||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
for (i = 1; i < pi->nr; i++) {
|
||||
entry++;
|
||||
if (entry->po2 >= prefs.pp_graphs.po2_threshold){
|
||||
to = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
QGraphicsLineItem *item = new QGraphicsLineItem(from.x(), from.y(), to.x(), to.y());
|
||||
item->setPen(QPen(c));
|
||||
scene()->addItem(item);
|
||||
from = to;
|
||||
}
|
||||
else{
|
||||
from = QPointF(SCALEGC(entry->sec, entry->po2));
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
void ProfileGraphicsView::plot_deco_text()
|
||||
{
|
||||
if (prefs.profile_calc_ceiling) {
|
||||
float x = gc.leftx + (gc.rightx - gc.leftx) / 2;
|
||||
float y = gc.topy = 1.0;
|
||||
static text_render_options_t tro = {PRESSURE_TEXT_SIZE, PRESSURE_TEXT, CENTER, -0.2};
|
||||
gc.bottomy = 0.0;
|
||||
plot_text(&tro, x, y, QString("GF %1/%2").arg(prefs.gflow * 100).arg(prefs.gfhigh * 100));
|
||||
}
|
||||
}
|
||||
|
||||
void ProfileGraphicsView::plot_cylinder_pressure_text()
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -104,6 +104,8 @@ private:
|
|||
void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro);
|
||||
void plot_cylinder_pressure_text();
|
||||
void plot_pressure_value(int mbar, int sec, int xalign, int yalign);
|
||||
void plot_deco_text();
|
||||
void plot_pp_gas_profile();
|
||||
|
||||
QColor get_sac_color(int sac, int avg_sac);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue