2014-01-14 18:20:15 +00:00
|
|
|
#include "divecartesianaxis.h"
|
|
|
|
#include "divelineitem.h"
|
|
|
|
#include "divetextitem.h"
|
|
|
|
#include "helpers.h"
|
2014-01-22 19:10:18 +00:00
|
|
|
#include "preferences.h"
|
2014-01-27 17:14:42 +00:00
|
|
|
#include "diveplotdatamodel.h"
|
|
|
|
#include "animationfunctions.h"
|
2014-01-14 18:20:15 +00:00
|
|
|
#include <QPen>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QGraphicsView>
|
|
|
|
#include <QStyleOption>
|
2014-01-22 19:10:18 +00:00
|
|
|
#include <QSettings>
|
2014-01-14 18:20:15 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
static QPen gridPen()
|
|
|
|
{
|
2014-01-19 22:14:48 +00:00
|
|
|
QPen pen;
|
|
|
|
pen.setColor(getColor(TIME_GRID));
|
|
|
|
pen.setWidth(2);
|
|
|
|
pen.setCosmetic(true);
|
|
|
|
return pen;
|
|
|
|
}
|
2014-02-07 16:59:58 +00:00
|
|
|
|
2014-02-07 19:59:21 +00:00
|
|
|
double DiveCartesianAxis::tickInterval() const
|
|
|
|
{
|
|
|
|
return interval;
|
|
|
|
}
|
|
|
|
|
|
|
|
double DiveCartesianAxis::tickSize() const
|
|
|
|
{
|
|
|
|
return tick_size;
|
|
|
|
}
|
|
|
|
|
2014-02-15 19:15:57 +00:00
|
|
|
void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
|
|
|
{
|
|
|
|
labelScale = scale;
|
|
|
|
}
|
|
|
|
|
2014-01-14 18:20:15 +00:00
|
|
|
void DiveCartesianAxis::setMaximum(double maximum)
|
|
|
|
{
|
2014-02-11 04:43:21 +00:00
|
|
|
if (IS_FP_SAME(max, maximum))
|
2014-02-04 21:21:57 +00:00
|
|
|
return;
|
2014-01-14 18:20:15 +00:00
|
|
|
max = maximum;
|
2014-01-27 17:14:42 +00:00
|
|
|
emit maxChanged();
|
2014-01-14 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DiveCartesianAxis::setMinimum(double minimum)
|
|
|
|
{
|
2014-02-11 04:43:21 +00:00
|
|
|
if (IS_FP_SAME(min, minimum))
|
2014-02-04 21:21:57 +00:00
|
|
|
return;
|
2014-01-14 18:20:15 +00:00
|
|
|
min = minimum;
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void DiveCartesianAxis::setTextColor(const QColor &color)
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
|
|
|
textColor = color;
|
|
|
|
}
|
|
|
|
|
2014-02-09 17:37:40 +00:00
|
|
|
DiveCartesianAxis::DiveCartesianAxis() : QObject(),
|
|
|
|
QGraphicsLineItem(),
|
|
|
|
unitSystem(0),
|
|
|
|
orientation(LeftToRight),
|
|
|
|
min(0),
|
|
|
|
max(0),
|
|
|
|
interval(1),
|
2014-02-12 16:24:19 +00:00
|
|
|
tick_size(0),
|
2014-02-16 18:44:23 +00:00
|
|
|
labelScale(1.0),
|
2014-02-15 23:55:31 +00:00
|
|
|
textVisibility(true),
|
2014-02-17 22:39:03 +00:00
|
|
|
lineVisibility(true),
|
2014-02-16 00:43:27 +00:00
|
|
|
line_size(1)
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
2014-01-19 22:14:48 +00:00
|
|
|
setPen(gridPen());
|
2014-01-14 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DiveCartesianAxis::~DiveCartesianAxis()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-15 23:55:31 +00:00
|
|
|
void DiveCartesianAxis::setLineSize(qreal lineSize)
|
|
|
|
{
|
|
|
|
line_size = lineSize;
|
|
|
|
}
|
|
|
|
|
2014-01-16 21:28:33 +00:00
|
|
|
void DiveCartesianAxis::setOrientation(Orientation o)
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
|
|
|
orientation = o;
|
|
|
|
}
|
|
|
|
|
2014-01-19 22:14:48 +00:00
|
|
|
QColor DiveCartesianAxis::colorForValue(double value)
|
|
|
|
{
|
|
|
|
return QColor(Qt::black);
|
|
|
|
}
|
|
|
|
|
2014-02-12 16:24:19 +00:00
|
|
|
void DiveCartesianAxis::setTextVisible(bool arg1)
|
|
|
|
{
|
2014-02-28 04:09:57 +00:00
|
|
|
if (textVisibility == arg1) {
|
2014-02-12 16:24:19 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
textVisibility = arg1;
|
2014-02-28 04:09:57 +00:00
|
|
|
Q_FOREACH(DiveTextItem * item, labels) {
|
2014-02-12 16:24:19 +00:00
|
|
|
item->setVisible(textVisibility);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-16 00:54:41 +00:00
|
|
|
void DiveCartesianAxis::setLinesVisible(bool arg1)
|
|
|
|
{
|
2014-02-28 04:09:57 +00:00
|
|
|
if (lineVisibility == arg1) {
|
2014-02-16 00:54:41 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-02-28 04:09:57 +00:00
|
|
|
lineVisibility = arg1;
|
|
|
|
Q_FOREACH(DiveLineItem * item, lines) {
|
|
|
|
item->setVisible(lineVisibility);
|
2014-02-16 00:54:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
template <typename T>
|
|
|
|
void emptyList(QList<T *> &list, double steps)
|
|
|
|
{
|
2014-02-15 23:55:31 +00:00
|
|
|
if (!list.isEmpty() && list.size() > steps) {
|
|
|
|
while (list.size() > steps) {
|
2014-02-28 04:09:57 +00:00
|
|
|
T *removedItem = list.takeLast();
|
|
|
|
Animations::animDelete(removedItem);
|
2014-02-15 23:55:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-14 18:20:15 +00:00
|
|
|
void DiveCartesianAxis::updateTicks()
|
|
|
|
{
|
2014-01-25 15:25:03 +00:00
|
|
|
if (!scene())
|
|
|
|
return;
|
2014-01-14 18:20:15 +00:00
|
|
|
QLineF m = line();
|
2014-01-16 05:44:18 +00:00
|
|
|
// unused so far:
|
|
|
|
// QGraphicsView *view = scene()->views().first();
|
2014-01-14 18:20:15 +00:00
|
|
|
double steps = (max - min) / interval;
|
2014-02-16 00:15:45 +00:00
|
|
|
double currValueText = min;
|
|
|
|
double currValueLine = min;
|
2014-01-14 18:20:15 +00:00
|
|
|
|
2014-01-27 17:14:42 +00:00
|
|
|
if (steps < 1)
|
|
|
|
return;
|
2014-01-27 19:09:08 +00:00
|
|
|
|
2014-02-15 23:55:31 +00:00
|
|
|
emptyList(labels, steps);
|
|
|
|
emptyList(lines, steps);
|
|
|
|
|
2014-01-14 18:24:33 +00:00
|
|
|
// Move the remaining Ticks / Text to it's corerct position
|
|
|
|
// Regartind the possibly new values for the Axis
|
2014-01-16 21:28:33 +00:00
|
|
|
qreal begin, stepSize;
|
|
|
|
if (orientation == TopToBottom) {
|
|
|
|
begin = m.y1();
|
|
|
|
stepSize = (m.y2() - m.y1());
|
|
|
|
} else if (orientation == BottomToTop) {
|
|
|
|
begin = m.y2();
|
|
|
|
stepSize = (m.y2() - m.y1());
|
2014-02-28 04:09:57 +00:00
|
|
|
} else if (orientation == LeftToRight) {
|
2014-01-16 21:28:33 +00:00
|
|
|
begin = m.x1();
|
|
|
|
stepSize = (m.x2() - m.x1());
|
|
|
|
} else if (orientation == RightToLeft) {
|
|
|
|
begin = m.x2();
|
|
|
|
stepSize = (m.x2() - m.x1());
|
|
|
|
}
|
2014-01-14 18:24:33 +00:00
|
|
|
stepSize = stepSize / steps;
|
2014-01-16 21:28:33 +00:00
|
|
|
|
2014-02-16 00:15:45 +00:00
|
|
|
for (int i = 0, count = labels.size(); i < count; i++, currValueText += interval) {
|
|
|
|
qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
|
2014-02-28 04:09:57 +00:00
|
|
|
begin + i * stepSize :
|
|
|
|
begin - i * stepSize;
|
2014-01-27 19:09:08 +00:00
|
|
|
|
2014-02-16 00:15:45 +00:00
|
|
|
labels[i]->setText(textForValue(currValueText));
|
2014-02-28 04:09:57 +00:00
|
|
|
if (orientation == LeftToRight || orientation == RightToLeft) {
|
2014-02-07 19:59:21 +00:00
|
|
|
labels[i]->animateMoveTo(childPos, m.y1() + tick_size);
|
2014-01-16 04:50:56 +00:00
|
|
|
} else {
|
2014-02-07 19:59:21 +00:00
|
|
|
labels[i]->animateMoveTo(m.x1() - tick_size, childPos);
|
2014-01-14 18:24:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-16 00:15:45 +00:00
|
|
|
for (int i = 0, count = lines.size(); i < count; i++, currValueLine += interval) {
|
|
|
|
qreal childPos = (orientation == TopToBottom || orientation == LeftToRight) ?
|
2014-02-28 04:09:57 +00:00
|
|
|
begin + i * stepSize :
|
|
|
|
begin - i * stepSize;
|
2014-02-16 00:15:45 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
if (orientation == LeftToRight || orientation == RightToLeft) {
|
2014-02-16 00:15:45 +00:00
|
|
|
lines[i]->animateMoveTo(childPos, m.y1());
|
|
|
|
} else {
|
|
|
|
lines[i]->animateMoveTo(m.x1(), childPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-14 18:28:07 +00:00
|
|
|
// Add's the rest of the needed Ticks / Text.
|
2014-02-28 04:09:57 +00:00
|
|
|
for (int i = labels.size(); i < steps; i++, currValueText += interval) {
|
2014-01-16 21:28:33 +00:00
|
|
|
qreal childPos;
|
|
|
|
if (orientation == TopToBottom || orientation == LeftToRight) {
|
2014-02-28 04:09:57 +00:00
|
|
|
childPos = begin + i * stepSize;
|
2014-01-16 21:28:33 +00:00
|
|
|
} else {
|
|
|
|
childPos = begin - i * stepSize;
|
|
|
|
}
|
2014-02-07 20:08:29 +00:00
|
|
|
DiveTextItem *label = new DiveTextItem(this);
|
2014-02-16 00:15:45 +00:00
|
|
|
label->setText(textForValue(currValueText));
|
2014-02-07 20:08:29 +00:00
|
|
|
label->setBrush(QBrush(textColor));
|
2014-02-16 00:15:45 +00:00
|
|
|
label->setBrush(colorForValue(currValueText));
|
2014-02-15 19:15:57 +00:00
|
|
|
label->setScale(fontLabelScale());
|
2014-02-16 00:49:30 +00:00
|
|
|
label->setZValue(1);
|
2014-02-07 20:08:29 +00:00
|
|
|
labels.push_back(label);
|
2014-01-16 21:28:33 +00:00
|
|
|
if (orientation == RightToLeft || orientation == LeftToRight) {
|
2014-02-07 20:08:29 +00:00
|
|
|
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
|
|
|
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene);
|
|
|
|
label->animateMoveTo(childPos, m.y1() + tick_size);
|
2014-01-16 04:50:56 +00:00
|
|
|
} else {
|
2014-02-28 04:09:57 +00:00
|
|
|
label->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
|
2014-02-07 20:08:29 +00:00
|
|
|
label->setPos(m.x1() - tick_size, scene()->sceneRect().height() + 10);
|
|
|
|
label->animateMoveTo(m.x1() - tick_size, childPos);
|
2014-01-14 18:28:07 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-12 16:24:19 +00:00
|
|
|
|
2014-02-16 00:43:27 +00:00
|
|
|
// Add's the rest of the needed Ticks / Text.
|
2014-02-28 04:09:57 +00:00
|
|
|
for (int i = lines.size(); i < steps; i++, currValueText += interval) {
|
2014-02-16 00:43:27 +00:00
|
|
|
qreal childPos;
|
|
|
|
if (orientation == TopToBottom || orientation == LeftToRight) {
|
2014-02-28 04:09:57 +00:00
|
|
|
childPos = begin + i * stepSize;
|
2014-02-16 00:43:27 +00:00
|
|
|
} else {
|
|
|
|
childPos = begin - i * stepSize;
|
|
|
|
}
|
|
|
|
DiveLineItem *line = new DiveLineItem(this);
|
|
|
|
QPen pen;
|
|
|
|
pen.setBrush(getColor(TIME_GRID));
|
|
|
|
pen.setCosmetic(true);
|
|
|
|
pen.setWidthF(2);
|
|
|
|
line->setPen(pen);
|
2014-02-16 00:49:30 +00:00
|
|
|
line->setZValue(0);
|
2014-02-16 00:43:27 +00:00
|
|
|
lines.push_back(line);
|
|
|
|
if (orientation == RightToLeft || orientation == LeftToRight) {
|
2014-02-28 04:09:57 +00:00
|
|
|
line->setLine(0, -line_size, 0, 0);
|
2014-02-16 00:43:27 +00:00
|
|
|
line->animateMoveTo(childPos, m.y1());
|
|
|
|
} else {
|
|
|
|
QPointF p1 = mapFromScene(3, 0);
|
|
|
|
QPointF p2 = mapFromScene(line_size, 0);
|
|
|
|
line->setLine(p1.x(), 0, p2.x(), 0);
|
|
|
|
line->animateMoveTo(m.x1(), childPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
Q_FOREACH(DiveTextItem * item, labels)
|
|
|
|
item->setVisible(textVisibility);
|
|
|
|
Q_FOREACH(DiveLineItem * item, lines)
|
|
|
|
item->setVisible(lineVisibility);
|
2014-01-14 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void DiveCartesianAxis::animateChangeLine(const QLineF &newLine)
|
2014-01-22 19:10:18 +00:00
|
|
|
{
|
|
|
|
setLine(newLine);
|
|
|
|
updateTicks();
|
|
|
|
sizeChanged();
|
|
|
|
}
|
|
|
|
|
2014-01-14 18:20:15 +00:00
|
|
|
QString DiveCartesianAxis::textForValue(double value)
|
|
|
|
{
|
|
|
|
return QString::number(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DiveCartesianAxis::setTickSize(qreal size)
|
|
|
|
{
|
2014-02-07 19:59:21 +00:00
|
|
|
tick_size = size;
|
2014-01-14 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DiveCartesianAxis::setTickInterval(double i)
|
|
|
|
{
|
|
|
|
interval = i;
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
qreal DiveCartesianAxis::valueAt(const QPointF &p) const
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
|
|
|
QLineF m = line();
|
2014-02-11 20:05:33 +00:00
|
|
|
QPointF relativePosition = p;
|
|
|
|
relativePosition -= pos(); // normalize p based on the axis' offset on screen
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
double retValue = (orientation == LeftToRight || orientation == RightToLeft) ?
|
|
|
|
max * (relativePosition.x() - m.x1()) / (m.x2() - m.x1()) :
|
|
|
|
max * (relativePosition.y() - m.y1()) / (m.y2() - m.y1());
|
2014-01-14 18:20:15 +00:00
|
|
|
return retValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal DiveCartesianAxis::posAtValue(qreal value)
|
|
|
|
{
|
|
|
|
QLineF m = line();
|
|
|
|
QPointF p = pos();
|
|
|
|
|
|
|
|
double size = max - min;
|
2014-01-16 23:30:47 +00:00
|
|
|
// unused for now:
|
|
|
|
// double distanceFromOrigin = value - min;
|
2014-02-28 04:09:57 +00:00
|
|
|
double percent = IS_FP_SAME(min, max) ? 0.0 : (value - min) / size;
|
2014-01-21 20:43:07 +00:00
|
|
|
|
2014-01-16 21:28:33 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
double realSize = orientation == LeftToRight || orientation == RightToLeft ?
|
|
|
|
m.x2() - m.x1() :
|
|
|
|
m.y2() - m.y1();
|
2014-01-16 21:28:33 +00:00
|
|
|
|
|
|
|
// Inverted axis, just invert the percentage.
|
2014-01-16 23:30:47 +00:00
|
|
|
if (orientation == RightToLeft || orientation == BottomToTop)
|
2014-01-16 21:28:33 +00:00
|
|
|
percent = 1 - percent;
|
|
|
|
|
2014-01-14 18:20:15 +00:00
|
|
|
double retValue = realSize * percent;
|
2014-01-16 21:28:33 +00:00
|
|
|
double adjusted =
|
2014-02-28 04:09:57 +00:00
|
|
|
orientation == LeftToRight ? retValue + m.x1() + p.x() :
|
|
|
|
orientation == RightToLeft ? retValue + m.x1() + p.x() :
|
|
|
|
orientation == TopToBottom ? retValue + m.y1() + p.y() :
|
|
|
|
/* entation == BottomToTop */ retValue + m.y1() + p.y();
|
2014-01-16 20:39:13 +00:00
|
|
|
return adjusted;
|
2014-01-14 18:20:15 +00:00
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
qreal DiveCartesianAxis::percentAt(const QPointF &p)
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
|
|
|
qreal value = valueAt(p);
|
|
|
|
double size = max - min;
|
|
|
|
double percent = value / size;
|
|
|
|
return percent;
|
|
|
|
}
|
|
|
|
|
|
|
|
double DiveCartesianAxis::maximum() const
|
|
|
|
{
|
|
|
|
return max;
|
|
|
|
}
|
|
|
|
|
|
|
|
double DiveCartesianAxis::minimum() const
|
|
|
|
{
|
|
|
|
return min;
|
|
|
|
}
|
|
|
|
|
2014-02-15 19:15:57 +00:00
|
|
|
double DiveCartesianAxis::fontLabelScale() const
|
|
|
|
{
|
|
|
|
return labelScale;
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void DiveCartesianAxis::setColor(const QColor &color)
|
2014-01-14 18:20:15 +00:00
|
|
|
{
|
|
|
|
QPen defaultPen(color);
|
|
|
|
defaultPen.setJoinStyle(Qt::RoundJoin);
|
|
|
|
defaultPen.setCapStyle(Qt::RoundCap);
|
|
|
|
defaultPen.setWidth(2);
|
|
|
|
defaultPen.setCosmetic(true);
|
|
|
|
setPen(defaultPen);
|
|
|
|
}
|
2014-01-15 12:54:33 +00:00
|
|
|
|
|
|
|
QString DepthAxis::textForValue(double value)
|
|
|
|
{
|
2014-02-15 22:48:58 +00:00
|
|
|
if (value == 0)
|
|
|
|
return QString();
|
2014-01-15 12:54:33 +00:00
|
|
|
return get_depth_string(value, false, false);
|
|
|
|
}
|
2014-01-15 13:08:31 +00:00
|
|
|
|
2014-01-19 22:14:48 +00:00
|
|
|
QColor DepthAxis::colorForValue(double value)
|
|
|
|
{
|
|
|
|
Q_UNUSED(value);
|
|
|
|
return QColor(Qt::red);
|
|
|
|
}
|
|
|
|
|
2014-02-05 20:58:21 +00:00
|
|
|
static bool isPPGraphEnabled()
|
|
|
|
{
|
|
|
|
QSettings s;
|
|
|
|
|
|
|
|
s.beginGroup("TecDetails");
|
|
|
|
return s.value("phegraph").toBool() || s.value("po2graph").toBool() || s.value("pn2graph").toBool();
|
|
|
|
}
|
|
|
|
|
2014-02-04 21:21:57 +00:00
|
|
|
DepthAxis::DepthAxis() : showWithPPGraph(false)
|
2014-01-22 19:10:18 +00:00
|
|
|
{
|
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
2014-02-05 20:58:21 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
// force the correct size of the line.
|
2014-02-05 20:58:21 +00:00
|
|
|
showWithPPGraph = !isPPGraphEnabled();
|
|
|
|
settingsChanged();
|
2014-01-22 19:10:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DepthAxis::settingsChanged()
|
|
|
|
{
|
2014-02-28 04:09:57 +00:00
|
|
|
// bool ppGraph = isPPGraphEnabled();
|
|
|
|
// if ( ppGraph == showWithPPGraph){
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// if (ppGraph) {
|
|
|
|
// animateChangeLine(shrinkedLine);
|
|
|
|
// } else {
|
|
|
|
// animateChangeLine(expandedLine);
|
|
|
|
// }
|
|
|
|
// showWithPPGraph = ppGraph;
|
2014-01-22 19:10:18 +00:00
|
|
|
}
|
|
|
|
|
2014-01-19 22:14:48 +00:00
|
|
|
QColor TimeAxis::colorForValue(double value)
|
|
|
|
{
|
|
|
|
Q_UNUSED(value);
|
|
|
|
return QColor(Qt::blue);
|
|
|
|
}
|
|
|
|
|
2014-01-15 13:08:31 +00:00
|
|
|
QString TimeAxis::textForValue(double value)
|
|
|
|
{
|
2014-01-27 19:09:08 +00:00
|
|
|
int nr = value / 60;
|
2014-02-28 04:09:57 +00:00
|
|
|
if (maximum() < 600)
|
|
|
|
return QString("%1:%2").arg(nr).arg((int)value % 60, 2, 10, QChar('0'));
|
|
|
|
return QString::number(nr);
|
2014-01-16 04:50:56 +00:00
|
|
|
}
|
2014-01-16 14:32:45 +00:00
|
|
|
|
2014-01-27 19:18:35 +00:00
|
|
|
void TimeAxis::updateTicks()
|
|
|
|
{
|
|
|
|
DiveCartesianAxis::updateTicks();
|
2014-02-28 04:09:57 +00:00
|
|
|
if (maximum() > 600) {
|
|
|
|
for (int i = 0; i < labels.count(); i++) {
|
2014-01-27 19:18:35 +00:00
|
|
|
labels[i]->setVisible(i % 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-16 20:39:13 +00:00
|
|
|
QString TemperatureAxis::textForValue(double value)
|
|
|
|
{
|
2014-02-28 04:09:57 +00:00
|
|
|
return QString::number(mkelvin_to_C((int)value));
|
2014-01-16 20:39:13 +00:00
|
|
|
}
|
|
|
|
|
2014-01-27 17:14:42 +00:00
|
|
|
PartialGasPressureAxis::PartialGasPressureAxis()
|
|
|
|
{
|
|
|
|
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(preferencesChanged()));
|
|
|
|
}
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
void PartialGasPressureAxis::setModel(DivePlotDataModel *m)
|
2014-01-27 17:14:42 +00:00
|
|
|
{
|
|
|
|
model = m;
|
|
|
|
connect(model, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(preferencesChanged()));
|
|
|
|
preferencesChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PartialGasPressureAxis::preferencesChanged()
|
|
|
|
{
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup("TecDetails");
|
|
|
|
bool showPhe = s.value("phegraph").toBool();
|
|
|
|
bool showPn2 = s.value("pn2graph").toBool();
|
|
|
|
bool showPo2 = s.value("po2graph").toBool();
|
|
|
|
setVisible(showPhe || showPn2 || showPo2);
|
|
|
|
if (!model->rowCount())
|
|
|
|
return;
|
|
|
|
|
|
|
|
double max = showPhe ? model->pheMax() : -1;
|
|
|
|
if (showPn2 && model->pn2Max() > max)
|
2014-02-28 04:09:57 +00:00
|
|
|
max = model->pn2Max();
|
|
|
|
if (showPo2 && model->po2Max() > max)
|
2014-01-27 17:14:42 +00:00
|
|
|
max = model->po2Max();
|
|
|
|
|
|
|
|
qreal pp = floor(max * 10.0) / 10.0 + 0.2;
|
2014-02-11 04:43:21 +00:00
|
|
|
if (IS_FP_SAME(maximum(), pp))
|
2014-02-04 21:21:57 +00:00
|
|
|
return;
|
|
|
|
|
2014-01-27 17:14:42 +00:00
|
|
|
setMaximum(pp);
|
2014-02-28 04:09:57 +00:00
|
|
|
setTickInterval(pp > 4 ? 0.5 : 0.25);
|
2014-01-27 17:14:42 +00:00
|
|
|
updateTicks();
|
|
|
|
}
|