mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 23:43:24 +00:00
profile: pass axes and model to DiveEventItem on construction
Firstly, there is no point in supporting DiveEventItems without model and axis. Secondly, this avoid pointless position- recalculations. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c93fb83edf
commit
fd2862042b
3 changed files with 14 additions and 29 deletions
|
@ -14,10 +14,12 @@
|
||||||
|
|
||||||
#define DEPTH_NOT_FOUND (-2342)
|
#define DEPTH_NOT_FOUND (-2342)
|
||||||
|
|
||||||
DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix, QGraphicsItem *parent) : DivePixmapItem(parent),
|
DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
|
||||||
vAxis(NULL),
|
DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
|
||||||
hAxis(NULL),
|
int speed, QGraphicsItem *parent) : DivePixmapItem(parent),
|
||||||
dataModel(NULL),
|
vAxis(vAxis),
|
||||||
|
hAxis(hAxis),
|
||||||
|
dataModel(model),
|
||||||
internalEvent(clone_event(ev)),
|
internalEvent(clone_event(ev)),
|
||||||
dive(d)
|
dive(d)
|
||||||
{
|
{
|
||||||
|
@ -26,6 +28,10 @@ DiveEventItem::DiveEventItem(const struct dive *d, struct event *ev, struct gasm
|
||||||
setupPixmap(lastgasmix);
|
setupPixmap(lastgasmix);
|
||||||
setupToolTipString(lastgasmix);
|
setupToolTipString(lastgasmix);
|
||||||
recalculatePos(0);
|
recalculatePos(0);
|
||||||
|
|
||||||
|
|
||||||
|
connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
|
||||||
|
[speed, this] { recalculatePos(speed); });
|
||||||
}
|
}
|
||||||
|
|
||||||
DiveEventItem::~DiveEventItem()
|
DiveEventItem::~DiveEventItem()
|
||||||
|
@ -33,26 +39,6 @@ DiveEventItem::~DiveEventItem()
|
||||||
free(internalEvent);
|
free(internalEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveEventItem::setHorizontalAxis(DiveCartesianAxis *axis)
|
|
||||||
{
|
|
||||||
hAxis = axis;
|
|
||||||
recalculatePos(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveEventItem::setModel(DivePlotDataModel *model)
|
|
||||||
{
|
|
||||||
dataModel = model;
|
|
||||||
recalculatePos(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void DiveEventItem::setVerticalAxis(DiveCartesianAxis *axis, int speed)
|
|
||||||
{
|
|
||||||
vAxis = axis;
|
|
||||||
recalculatePos(0);
|
|
||||||
connect(vAxis, &DiveCartesianAxis::sizeChanged, this,
|
|
||||||
[speed, this] { recalculatePos(speed); });
|
|
||||||
}
|
|
||||||
|
|
||||||
struct event *DiveEventItem::getEvent()
|
struct event *DiveEventItem::getEvent()
|
||||||
{
|
{
|
||||||
return internalEvent;
|
return internalEvent;
|
||||||
|
|
|
@ -11,7 +11,9 @@ struct event;
|
||||||
class DiveEventItem : public DivePixmapItem {
|
class DiveEventItem : public DivePixmapItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix, QGraphicsItem *parent = 0);
|
DiveEventItem(const struct dive *d, struct event *ev, struct gasmix lastgasmix,
|
||||||
|
DivePlotDataModel *model, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis,
|
||||||
|
int speed, QGraphicsItem *parent = nullptr);
|
||||||
~DiveEventItem();
|
~DiveEventItem();
|
||||||
struct event *getEvent();
|
struct event *getEvent();
|
||||||
void eventVisibilityChanged(const QString &eventName, bool visible);
|
void eventVisibilityChanged(const QString &eventName, bool visible);
|
||||||
|
|
|
@ -725,10 +725,7 @@ void ProfileWidget2::plotDive(const struct dive *dIn, int dcIn, bool doClearPict
|
||||||
// printMode is always selected for SUBSURFACE_MOBILE due to font problems
|
// printMode is always selected for SUBSURFACE_MOBILE due to font problems
|
||||||
// BUT events are wanted.
|
// BUT events are wanted.
|
||||||
#endif
|
#endif
|
||||||
DiveEventItem *item = new DiveEventItem(d, event, lastgasmix);
|
DiveEventItem *item = new DiveEventItem(d, event, lastgasmix, dataModel, timeAxis, profileYAxis, animSpeed);
|
||||||
item->setHorizontalAxis(timeAxis);
|
|
||||||
item->setVerticalAxis(profileYAxis, qPrefDisplay::animation_speed());
|
|
||||||
item->setModel(dataModel);
|
|
||||||
item->setZValue(2);
|
item->setZValue(2);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
#ifndef SUBSURFACE_MOBILE
|
||||||
item->setScale(printMode ? 4 :1);
|
item->setScale(printMode ? 4 :1);
|
||||||
|
|
Loading…
Add table
Reference in a new issue