mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: reimplement DivePercentageItem
The tissue percentages were realized as 16 independent polygons. That didn't work at all with the new absolute scaling. Reimplement the item and blast it onto a pixmap. Not only is this artifact-free, it also should (hopefully) be quite a bit more efficient than painting numerous lines. In contrast to the old code, this does access the plot_info structure directly instead of using the model. Not so much for performance reason, but rather to make things more robust: We have a strongly typed language. Why would we shoehorn data through the weakly typed QVariant and mess with wierd index-arithmetics. Makes no sense to me. Qt-model have to be used for interfacing with Qt. They are terrible for intra-application data transfer. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
24cf6709e3
commit
505e4e47eb
10 changed files with 177 additions and 89 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "profilescene.h"
|
||||
#include "diveeventitem.h"
|
||||
#include "divecartesianaxis.h"
|
||||
#include "divepercentageitem.h"
|
||||
#include "diveprofileitem.h"
|
||||
#include "divetextitem.h"
|
||||
#include "tankitem.h"
|
||||
|
@ -69,6 +70,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
|||
diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, dpr)),
|
||||
decoModelParameters(new DiveTextItem(dpr, 1.0, Qt::AlignHCenter | Qt::AlignTop, nullptr)),
|
||||
heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1, dpr)),
|
||||
percentageItem(new DivePercentageItem(*timeAxis, *percentageAxis, dpr)),
|
||||
tankItem(new TankItem(*timeAxis, dpr))
|
||||
{
|
||||
init_plot_info(&plotInfo);
|
||||
|
@ -119,10 +121,10 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
|||
for (int i = 0; i < 16; i++) {
|
||||
DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1, dpr);
|
||||
allTissues.append(tissueItem);
|
||||
DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i, dpr);
|
||||
allPercentages.append(percentageItem);
|
||||
}
|
||||
|
||||
percentageItem->setZValue(1.0);
|
||||
|
||||
// Add items to scene
|
||||
addItem(diveComputerText);
|
||||
addItem(tankItem);
|
||||
|
@ -134,6 +136,7 @@ ProfileScene::ProfileScene(double dpr, bool printMode, bool isGrayscale) :
|
|||
addItem(cylinderPressureAxis);
|
||||
addItem(percentageAxis);
|
||||
addItem(heartBeatAxis);
|
||||
addItem(percentageItem);
|
||||
|
||||
for (AbstractProfilePolygonItem *item: profileItems)
|
||||
addItem(item);
|
||||
|
@ -189,8 +192,7 @@ void ProfileScene::updateVisibility()
|
|||
#ifndef SUBSURFACE_MOBILE
|
||||
for (DiveCalculatedTissue *tissue: allTissues)
|
||||
tissue->setVisible(prefs.calcalltissues && prefs.calcceiling);
|
||||
for (DivePercentageItem *percentage: allPercentages)
|
||||
percentage->setVisible(prefs.percentagegraph);
|
||||
percentageItem->setVisible(prefs.percentagegraph);
|
||||
#endif
|
||||
meanDepthItem->setVisible(prefs.show_average_depth);
|
||||
reportedCeiling->setVisible(prefs.dcceiling);
|
||||
|
@ -468,6 +470,9 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
|||
for (AbstractProfilePolygonItem *item: profileItems)
|
||||
item->replot(d, inPlanner);
|
||||
|
||||
if (prefs.percentagegraph)
|
||||
percentageItem->replot(d, currentdc, dataModel->data());
|
||||
|
||||
// The event items are a bit special since we don't know how many events are going to
|
||||
// exist on a dive, so I cant create cache items for that. that's why they are here
|
||||
// while all other items are up there on the constructor.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue