mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 00:03:24 +00:00
Add the depth text.
Depth text got added to the new profile. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
caba6500d6
commit
0a4e21a168
6 changed files with 48 additions and 2 deletions
|
@ -45,6 +45,11 @@ QVariant DivePlotDataModel::data(const QModelIndex& index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plot_data* DivePlotDataModel::data()
|
||||||
|
{
|
||||||
|
return plotData;
|
||||||
|
}
|
||||||
|
|
||||||
int DivePlotDataModel::rowCount(const QModelIndex& parent) const
|
int DivePlotDataModel::rowCount(const QModelIndex& parent) const
|
||||||
{
|
{
|
||||||
return sampleCount;
|
return sampleCount;
|
||||||
|
|
|
@ -18,6 +18,7 @@ public:
|
||||||
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
||||||
void clear();
|
void clear();
|
||||||
void setDive(struct dive *d, const plot_info& pInfo);
|
void setDive(struct dive *d, const plot_info& pInfo);
|
||||||
|
plot_data* data();
|
||||||
private:
|
private:
|
||||||
int sampleCount;
|
int sampleCount;
|
||||||
plot_data *plotData;
|
plot_data *plotData;
|
||||||
|
|
|
@ -103,6 +103,42 @@ void DiveProfileItem::modelDataChanged(){
|
||||||
pat.setColorAt(1, getColor(DEPTH_BOTTOM));
|
pat.setColorAt(1, getColor(DEPTH_BOTTOM));
|
||||||
pat.setColorAt(0, getColor(DEPTH_TOP));
|
pat.setColorAt(0, getColor(DEPTH_TOP));
|
||||||
setBrush(QBrush(pat));
|
setBrush(QBrush(pat));
|
||||||
|
|
||||||
|
qDeleteAll(texts);
|
||||||
|
texts.clear();
|
||||||
|
|
||||||
|
int last = -1;
|
||||||
|
for (int i = 0, count = dataModel->rowCount(); i < count; i++) {
|
||||||
|
|
||||||
|
struct plot_data *entry = static_cast<DivePlotDataModel*>(dataModel)->data()+i;
|
||||||
|
if (entry->depth < 2000)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ((entry == entry->max[2]) && entry->depth / 100 != last) {
|
||||||
|
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignTop, getColor(SAMPLE_DEEP));
|
||||||
|
last = entry->depth / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((entry == entry->min[2]) && entry->depth / 100 != last) {
|
||||||
|
plot_depth_sample(entry, Qt::AlignHCenter | Qt::AlignBottom, getColor(SAMPLE_SHALLOW));
|
||||||
|
last = entry->depth / 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry->depth != last)
|
||||||
|
last = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DiveProfileItem::plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color)
|
||||||
|
{
|
||||||
|
int decimals;
|
||||||
|
double d = get_depth_units(entry->depth, &decimals, NULL);
|
||||||
|
DiveTextItem *item = new DiveTextItem(this);
|
||||||
|
item->setPos(hAxis->posAtValue(entry->sec), vAxis->posAtValue(entry->depth));
|
||||||
|
item->setText(QString("%1").arg(d, 0, 'f', 1));
|
||||||
|
item->setAlignment(flags);
|
||||||
|
item->setBrush(color);
|
||||||
|
texts.append(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveTemperatureItem::DiveTemperatureItem()
|
DiveTemperatureItem::DiveTemperatureItem()
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
class DiveTextItem;
|
class DiveTextItem;
|
||||||
class DiveCartesianAxis;
|
class DiveCartesianAxis;
|
||||||
class QAbstractTableModel;
|
class QAbstractTableModel;
|
||||||
|
struct plot_data;
|
||||||
|
|
||||||
class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem{
|
class AbstractProfilePolygonItem : public QObject, public QGraphicsPolygonItem{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -43,13 +44,16 @@ protected:
|
||||||
QAbstractTableModel *dataModel;
|
QAbstractTableModel *dataModel;
|
||||||
int hDataColumn;
|
int hDataColumn;
|
||||||
int vDataColumn;
|
int vDataColumn;
|
||||||
|
QList<DiveTextItem*> texts;
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiveProfileItem : public AbstractProfilePolygonItem{
|
class DiveProfileItem : public AbstractProfilePolygonItem{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
||||||
virtual void modelDataChanged();
|
virtual void modelDataChanged();
|
||||||
|
void plot_depth_sample(struct plot_data *entry,QFlags<Qt::AlignmentFlag> flags,const QColor& color);
|
||||||
};
|
};
|
||||||
|
|
||||||
class DiveTemperatureItem : public AbstractProfilePolygonItem{
|
class DiveTemperatureItem : public AbstractProfilePolygonItem{
|
||||||
|
|
|
@ -359,7 +359,7 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
|
||||||
scene()->addItem(gasPressureItem);
|
scene()->addItem(gasPressureItem);
|
||||||
|
|
||||||
diveComputerText->setText(currentdc->model);
|
diveComputerText->setText(currentdc->model);
|
||||||
diveComputerText->setPos(1 , sceneRect().height());
|
diveComputerText->animateMoveTo(1 , sceneRect().height());
|
||||||
|
|
||||||
emit startProfileState();
|
emit startProfileState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,7 +162,7 @@ private:
|
||||||
void plot_single_temp_text(int sec, int mkelvin);
|
void plot_single_temp_text(int sec, int mkelvin);
|
||||||
void plot_depth_text();
|
void plot_depth_text();
|
||||||
void plot_text_samples();
|
void plot_text_samples();
|
||||||
void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro);
|
void plot_depth_sample(plot_data* entry, text_render_options_t* tro);
|
||||||
void plot_cylinder_pressure_text();
|
void plot_cylinder_pressure_text();
|
||||||
void plot_pressure_value(int mbar, int sec, double xalign, double yalign);
|
void plot_pressure_value(int mbar, int sec, double xalign, double yalign);
|
||||||
void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he);
|
void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he);
|
||||||
|
|
Loading…
Add table
Reference in a new issue