2015-07-17 16:09:42 +00:00
|
|
|
#include "qmlprofile.h"
|
2015-11-05 15:59:09 +00:00
|
|
|
#include "profile-widget/profilewidget2.h"
|
|
|
|
#include "subsurface-core/dive.h"
|
2015-07-25 16:10:51 +00:00
|
|
|
#include <QTransform>
|
2015-07-17 16:09:42 +00:00
|
|
|
|
|
|
|
QMLProfile::QMLProfile(QQuickItem *parent) :
|
2015-12-29 17:50:47 +00:00
|
|
|
QQuickPaintedItem(parent),
|
|
|
|
m_margin(0)
|
2015-07-17 16:09:42 +00:00
|
|
|
{
|
2015-12-29 17:51:34 +00:00
|
|
|
setAntialiasing(true);
|
2015-11-12 00:43:13 +00:00
|
|
|
m_profileWidget = new ProfileWidget2(0);
|
|
|
|
m_profileWidget->setProfileState();
|
2015-12-29 15:15:52 +00:00
|
|
|
m_profileWidget->setPrintMode(true);
|
|
|
|
m_profileWidget->setFontPrintScale(0.8);
|
2015-11-12 00:43:13 +00:00
|
|
|
//m_profileWidget->setGeometry(this->geometry());
|
|
|
|
}
|
|
|
|
|
|
|
|
QMLProfile::~QMLProfile()
|
|
|
|
{
|
|
|
|
m_profileWidget->deleteLater();
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QMLProfile::paint(QPainter *painter)
|
|
|
|
{
|
2015-11-12 00:43:13 +00:00
|
|
|
m_profileWidget->render(painter);
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|
|
|
|
|
2015-12-29 17:50:47 +00:00
|
|
|
void QMLProfile::setMargin(int margin)
|
|
|
|
{
|
|
|
|
m_margin = margin;
|
|
|
|
}
|
|
|
|
|
2015-07-17 16:09:42 +00:00
|
|
|
QString QMLProfile::diveId() const
|
|
|
|
{
|
|
|
|
return m_diveId;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QMLProfile::setDiveId(const QString &diveId)
|
|
|
|
{
|
2015-12-26 00:53:57 +00:00
|
|
|
static bool firstRun = true;
|
|
|
|
static QTransform profileTransform;
|
2015-07-17 16:09:42 +00:00
|
|
|
m_diveId = diveId;
|
2015-12-01 23:22:38 +00:00
|
|
|
struct dive *d = get_dive_by_uniq_id(m_diveId.toInt());
|
|
|
|
if (m_diveId.toInt() < 1)
|
|
|
|
return;
|
|
|
|
if (!d)
|
|
|
|
return;
|
|
|
|
|
2015-12-26 00:53:57 +00:00
|
|
|
qDebug() << "setDiveId called with pos/size" << x() << y() << width() << height();
|
2015-12-02 19:26:32 +00:00
|
|
|
// set the profile widget's geometry and scale the viewport so
|
|
|
|
// the scene fills it, then plot the dive on that widget
|
2015-12-26 00:53:57 +00:00
|
|
|
if (firstRun) {
|
|
|
|
firstRun = false;
|
2015-12-30 13:22:30 +00:00
|
|
|
m_profileWidget->setGeometry(QRect(x(), y(), width(), height()));
|
|
|
|
profileTransform.scale(width() / 100, height() / 100);
|
2015-12-26 00:53:57 +00:00
|
|
|
}
|
2015-12-02 19:26:32 +00:00
|
|
|
m_profileWidget->setTransform(profileTransform);
|
2015-12-26 00:53:57 +00:00
|
|
|
qDebug() << "effective transformation:" <<
|
|
|
|
m_profileWidget->transform().m11() <<
|
|
|
|
m_profileWidget->transform().m12() <<
|
|
|
|
m_profileWidget->transform().m13() <<
|
|
|
|
m_profileWidget->transform().m21() <<
|
|
|
|
m_profileWidget->transform().m22() <<
|
|
|
|
m_profileWidget->transform().m23() <<
|
|
|
|
m_profileWidget->transform().m31() <<
|
|
|
|
m_profileWidget->transform().m32() <<
|
|
|
|
m_profileWidget->transform().m33();
|
|
|
|
|
2015-12-01 23:22:38 +00:00
|
|
|
m_profileWidget->plotDive(d);
|
2015-12-30 13:22:30 +00:00
|
|
|
// scale the profile to create a margin
|
|
|
|
m_profileWidget->scale(0.95, 0.95);
|
2015-07-17 16:09:42 +00:00
|
|
|
}
|