Show the profile again.

This patch re-enables a few items on the profile, most notably, the
profile itself.

Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Tomaz Canabrava 2014-02-07 17:59:21 -02:00 committed by Dirk Hohndel
parent ed72aabde5
commit 0ad2a69c42
5 changed files with 43 additions and 20 deletions

View file

@ -30,4 +30,10 @@ void moveTo(QObject* obj, qreal x, qreal y, int msecs)
animation->start(QAbstractAnimation::DeleteWhenStopped);
}
void moveTo(QObject* obj, const QPointF& pos, int msecs)
{
moveTo(obj, pos.x(), pos.y(), msecs);
}
}

View file

@ -2,11 +2,14 @@
#define ANIMATIONFUNCTIONS_H
#include <QtGlobal>
#include <QPointF>
class QObject;
namespace Animations{
void hide(QObject *obj);
void moveTo(QObject *obj, qreal x, qreal y, int msecs = 500);
void moveTo(QObject *obj, const QPointF& pos, int msecs = 500);
void animDelete(QObject *obj);
};

View file

@ -20,16 +20,26 @@ static QPen gridPen(){
return pen;
}
void DiveCartesianAxis::setup(double minimum, double maximum, double interval, DiveCartesianAxis::Orientation o, qreal tickSize, const QPointF& pos)
void DiveCartesianAxis::setup(double minimum, double maximum, double interval, DiveCartesianAxis::Orientation o, qreal tick_size, const QPointF& pos)
{
setMinimum(minimum);
setMaximum(maximum);
setTickInterval(interval);
setOrientation(o);
setTickSize(tickSize);
setTickSize(tick_size);
setPos(pos);
}
double DiveCartesianAxis::tickInterval() const
{
return interval;
}
double DiveCartesianAxis::tickSize() const
{
return tick_size;
}
void DiveCartesianAxis::setMaximum(double maximum)
{
if (max == maximum)
@ -121,9 +131,9 @@ void DiveCartesianAxis::updateTicks()
labels[i]->setText(textForValue(currValue));
if ( orientation == LeftToRight || orientation == RightToLeft) {
labels[i]->animateMoveTo(childPos, m.y1() + tickSize);
labels[i]->animateMoveTo(childPos, m.y1() + tick_size);
} else {
labels[i]->animateMoveTo(m.x1() - tickSize, childPos);
labels[i]->animateMoveTo(m.x1() - tick_size, childPos);
}
}
@ -147,14 +157,14 @@ void DiveCartesianAxis::updateTicks()
if (orientation == RightToLeft || orientation == LeftToRight) {
if(showText){
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tickSize); // position it outside of the scene);
label->animateMoveTo(childPos, m.y1() + tickSize);
label->setPos(scene()->sceneRect().width() + 10, m.y1() + tick_size); // position it outside of the scene);
label->animateMoveTo(childPos, m.y1() + tick_size);
}
} else {
if(showText){
label->setAlignment(Qt::AlignVCenter| Qt::AlignLeft);
label->setPos(m.x1() - tickSize, scene()->sceneRect().height() + 10);
label->animateMoveTo(m.x1() - tickSize, childPos);
label->setPos(m.x1() - tick_size, scene()->sceneRect().height() + 10);
label->animateMoveTo(m.x1() - tick_size, childPos);
}
}
}
@ -186,7 +196,7 @@ QString DiveCartesianAxis::textForValue(double value)
void DiveCartesianAxis::setTickSize(qreal size)
{
tickSize = size;
tick_size = size;
}
void DiveCartesianAxis::setTickInterval(double i)

View file

@ -27,6 +27,8 @@ public:
void setTickSize(qreal size);
double minimum() const;
double maximum() const;
double tickInterval() const;
double tickSize() const;
qreal valueAt(const QPointF& p);
qreal percentAt(const QPointF& p);
qreal posAtValue(qreal value);
@ -49,7 +51,7 @@ protected:
double min;
double max;
double interval;
double tickSize;
double tick_size;
QColor textColor;
bool showTicks;
bool showText;

View file

@ -117,8 +117,12 @@ void ProfileWidget2::setupItemOnScene()
background->setZValue(9999);
toolTipItem->setTimeAxis(timeAxis);
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
profileYAxis->setMinimum(0);
profileYAxis->setTickInterval(M_OR_FT(10,30));
profileYAxis->setTickSize(2);
gasYAxis->setOrientation(DiveCartesianAxis::BottomToTop);
gasYAxis->setX(3);
gasYAxis->setTickInterval(1);
gasYAxis->setTickSize(2);
gasYAxis->setY(70);
@ -126,12 +130,10 @@ void ProfileWidget2::setupItemOnScene()
gasYAxis->setModel(dataModel);
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
temperatureAxis->setX(3);
temperatureAxis->setTickSize(2);
temperatureAxis->setTickInterval(300);
cylinderPressureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
cylinderPressureAxis->setX(3);
cylinderPressureAxis->setTickSize(2);
cylinderPressureAxis->setTickInterval(30000);
@ -265,6 +267,8 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
profileYAxis->setMaximum(maxdepth);
profileYAxis->updateTicks();
qDebug() << "More profile..." << profileYAxis->minimum() << profileYAxis->maximum() << profileYAxis->tickInterval() << profileYAxis->tickSize();
temperatureAxis->setMinimum(pInfo.mintemp);
temperatureAxis->setMaximum(pInfo.maxtemp);
timeAxis->setMaximum(maxtime);
@ -400,11 +404,11 @@ void ProfileWidget2::setEmptyState()
currentState = EMPTY;
fixBackgroundPos();
Animations::moveTo(background, background->x(), itemPos.background.on.y());
profileYAxis->setPos(itemPos.depth.pos.off);
Animations::moveTo(profileYAxis, itemPos.depth.pos.off);
toolTipItem->setVisible(false);
gasYAxis->setVisible(false);
temperatureAxis->setVisible(false);
timeAxis->setPos(itemPos.time.pos.off);
Animations::moveTo(timeAxis,itemPos.time.pos.off);
diveProfileItem->setVisible(false);
cylinderPressureAxis->setVisible(false);
temperatureItem->setVisible(false);
@ -437,16 +441,14 @@ void ProfileWidget2::setProfileState()
Animations::moveTo(background, background->x(), itemPos.background.off.y(), 1500);
toolTipItem->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on);
Animations::moveTo(profileYAxis,itemPos.depth.pos.on);
profileYAxis->setLine(itemPos.depth.expanded);
qDebug() << "ProfileAxisPos" << profileYAxis->pos() << "Line" << profileYAxis->line() << scene()->items().indexOf(profileYAxis);
// gasYAxis->setVisible(true);
// temperatureAxis->setVisible(true);
timeAxis->setPos(itemPos.time.pos.on);
Animations::moveTo(timeAxis, itemPos.time.pos.on);
timeAxis->setLine(itemPos.time.expanded);
qDebug() << "timeAxisPos" << timeAxis->pos() << "Line" << timeAxis->line() << scene()->items().indexOf(timeAxis);
// diveProfileItem->setVisible(true);
diveProfileItem->setVisible(true);
// cylinderPressureAxis->setVisible(true);
// temperatureItem->setVisible(true);
// gasPressureItem->setVisible(true);