mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: pass print-mode add construction of ProfileScene
Setting the profile and grayscale mode of the profile via functions is from a time when the same profile widget was used for printing and the UI. It is simpler to set the mode when constructing the object and not deal with changes. To prepare for this scenario, take the flag at construction time. This still keeps the callers as-is. These will be adapted later. Logically, then the printFlag also has to be set in DiveCartesianAxis at construction time. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1327043d6e
commit
84ebd1d67a
5 changed files with 23 additions and 45 deletions
|
@ -26,18 +26,6 @@ void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
|||
changed = true;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setPrintMode()
|
||||
{
|
||||
printMode = true;
|
||||
// update the QPen of all lines depending on printMode
|
||||
QPen newPen = gridPen();
|
||||
QColor oldColor = pen().brush().color();
|
||||
newPen.setBrush(oldColor);
|
||||
setPen(newPen);
|
||||
Q_FOREACH (DiveLineItem *item, lines)
|
||||
item->setPen(pen());
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setMaximum(double maximum)
|
||||
{
|
||||
if (IS_FP_SAME(max, maximum))
|
||||
|
@ -59,9 +47,8 @@ void DiveCartesianAxis::setTextColor(const QColor &color)
|
|||
textColor = color;
|
||||
}
|
||||
|
||||
DiveCartesianAxis::DiveCartesianAxis(double fontPrintScale, ProfileScene &scene) : QObject(),
|
||||
QGraphicsLineItem(),
|
||||
printMode(false),
|
||||
DiveCartesianAxis::DiveCartesianAxis(double fontPrintScale, bool printMode, ProfileScene &scene) :
|
||||
printMode(printMode),
|
||||
scene(scene),
|
||||
orientation(LeftToRight),
|
||||
min(0),
|
||||
|
@ -352,7 +339,7 @@ QColor DepthAxis::colorForValue(double) const
|
|||
return QColor(Qt::red);
|
||||
}
|
||||
|
||||
DepthAxis::DepthAxis(double fontPrintScale, ProfileScene &scene) : DiveCartesianAxis(fontPrintScale, scene)
|
||||
DepthAxis::DepthAxis(double fontPrintScale, bool printMode, ProfileScene &scene) : DiveCartesianAxis(fontPrintScale, printMode, scene)
|
||||
{
|
||||
changed = true;
|
||||
}
|
||||
|
@ -385,8 +372,8 @@ QString TemperatureAxis::textForValue(double value) const
|
|||
return QString::number(mkelvin_to_C((int)value));
|
||||
}
|
||||
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, ProfileScene &scene) :
|
||||
DiveCartesianAxis(fontPrintScale, scene),
|
||||
PartialGasPressureAxis::PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, bool printMode, ProfileScene &scene) :
|
||||
DiveCartesianAxis(fontPrintScale, printMode, scene),
|
||||
model(model)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -29,9 +29,8 @@ public:
|
|||
LeftToRight,
|
||||
RightToLeft
|
||||
};
|
||||
DiveCartesianAxis(double fontPrintScale, ProfileScene &scene);
|
||||
DiveCartesianAxis(double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
~DiveCartesianAxis();
|
||||
void setPrintMode();
|
||||
void setMinimum(double minimum);
|
||||
void setMaximum(double maximum);
|
||||
void setTickInterval(double interval);
|
||||
|
@ -77,7 +76,7 @@ protected:
|
|||
class DepthAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
DepthAxis(double fontPrintScale, ProfileScene &scene);
|
||||
DepthAxis(double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
private:
|
||||
QString textForValue(double value) const override;
|
||||
QColor colorForValue(double value) const override;
|
||||
|
@ -104,7 +103,7 @@ private:
|
|||
class PartialGasPressureAxis : public DiveCartesianAxis {
|
||||
Q_OBJECT
|
||||
public:
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, ProfileScene &scene);
|
||||
PartialGasPressureAxis(const DivePlotDataModel &model, double fontPrintScale, bool printMode, ProfileScene &scene);
|
||||
void update(int animSpeed);
|
||||
private:
|
||||
const DivePlotDataModel &model;
|
||||
|
|
|
@ -61,22 +61,22 @@ PartialPressureGasItem *ProfileScene::createPPGas(int column, color_index_t colo
|
|||
return item;
|
||||
}
|
||||
|
||||
ProfileScene::ProfileScene(double fontPrintScale) :
|
||||
ProfileScene::ProfileScene(double fontPrintScale, bool printMode, bool isGrayscale) :
|
||||
d(nullptr),
|
||||
dc(-1),
|
||||
fontPrintScale(fontPrintScale),
|
||||
printMode(false),
|
||||
isGrayscale(false),
|
||||
printMode(printMode),
|
||||
isGrayscale(isGrayscale),
|
||||
maxtime(-1),
|
||||
maxdepth(-1),
|
||||
dataModel(new DivePlotDataModel(this)),
|
||||
profileYAxis(new DepthAxis(fontPrintScale, *this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, fontPrintScale, *this)),
|
||||
temperatureAxis(new TemperatureAxis(fontPrintScale, *this)),
|
||||
timeAxis(new TimeAxis(fontPrintScale, *this)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(fontPrintScale, *this)),
|
||||
heartBeatAxis(new DiveCartesianAxis(fontPrintScale, *this)),
|
||||
percentageAxis(new DiveCartesianAxis(fontPrintScale, *this)),
|
||||
profileYAxis(new DepthAxis(fontPrintScale, printMode, *this)),
|
||||
gasYAxis(new PartialGasPressureAxis(*dataModel, fontPrintScale, printMode, *this)),
|
||||
temperatureAxis(new TemperatureAxis(fontPrintScale, printMode, *this)),
|
||||
timeAxis(new TimeAxis(fontPrintScale, printMode, *this)),
|
||||
cylinderPressureAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
heartBeatAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
percentageAxis(new DiveCartesianAxis(fontPrintScale, printMode, *this)),
|
||||
diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0, fontPrintScale)),
|
||||
temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1, fontPrintScale)),
|
||||
meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1, fontPrintScale)),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Displays the dive profile. Used by the interactive profile widget
|
||||
// and the printing/exporting code.
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
// Displays the dive profile. Used by the interactive profile widget
|
||||
// and the printing/exporting code.
|
||||
#ifndef PROFILESCENE_H
|
||||
#define PROFILESCENE_H
|
||||
|
||||
|
@ -35,7 +35,7 @@ class TimeAxis;
|
|||
|
||||
class ProfileScene : public QGraphicsScene {
|
||||
public:
|
||||
ProfileScene(double fontPrintScale);
|
||||
ProfileScene(double fontPrintScale, bool printMode, bool isGrayscale);
|
||||
~ProfileScene();
|
||||
|
||||
void updateAxes(bool instant); // Update axes according to preferences
|
||||
|
|
|
@ -46,7 +46,7 @@ static const double thumbnailBaseZValue = 100.0;
|
|||
#endif
|
||||
|
||||
ProfileWidget2::ProfileWidget2(DivePlannerPointsModel *plannerModelIn, double fontPrintScale, QWidget *parent) : QGraphicsView(parent),
|
||||
profileScene(new ProfileScene(fontPrintScale)),
|
||||
profileScene(new ProfileScene(fontPrintScale, false, false)),
|
||||
currentState(INIT),
|
||||
plannerModel(plannerModelIn),
|
||||
zoomLevel(0),
|
||||
|
@ -821,16 +821,8 @@ void ProfileWidget2::setPrintMode(bool grayscale)
|
|||
resetZoom();
|
||||
|
||||
// set printMode for axes
|
||||
profileScene->profileYAxis->setPrintMode();
|
||||
profileScene->gasYAxis->setPrintMode();
|
||||
profileScene->temperatureAxis->setPrintMode();
|
||||
profileScene->timeAxis->setPrintMode();
|
||||
profileScene->cylinderPressureAxis->setPrintMode();
|
||||
profileScene->isGrayscale = grayscale;
|
||||
#ifndef SUBSURFACE_MOBILE
|
||||
profileScene->heartBeatAxis->setPrintMode();
|
||||
profileScene->percentageAxis->setPrintMode();
|
||||
|
||||
mouseFollowerHorizontal->setVisible(false);
|
||||
mouseFollowerVertical->setVisible(false);
|
||||
toolTipItem->setVisible(false);
|
||||
|
|
Loading…
Add table
Reference in a new issue