mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make font label scale a per axis property
This way the partial pressure graph can have smaller pressure labels than all the other labels on the profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
980737221d
commit
6be62c1d90
3 changed files with 20 additions and 3 deletions
|
@ -20,7 +20,8 @@ static QPen gridPen(){
|
|||
return pen;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setup(double minimum, double maximum, double interval, DiveCartesianAxis::Orientation o, qreal tick_size, const QPointF& pos)
|
||||
void DiveCartesianAxis::setup(double minimum, double maximum, double interval, double labelFontScale,
|
||||
DiveCartesianAxis::Orientation o, qreal tick_size, const QPointF& pos)
|
||||
{
|
||||
setMinimum(minimum);
|
||||
setMaximum(maximum);
|
||||
|
@ -28,6 +29,7 @@ void DiveCartesianAxis::setup(double minimum, double maximum, double interval, D
|
|||
setOrientation(o);
|
||||
setTickSize(tick_size);
|
||||
setPos(pos);
|
||||
setFontLabelScale(labelFontScale);
|
||||
}
|
||||
|
||||
double DiveCartesianAxis::tickInterval() const
|
||||
|
@ -40,6 +42,11 @@ double DiveCartesianAxis::tickSize() const
|
|||
return tick_size;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setFontLabelScale(qreal scale)
|
||||
{
|
||||
labelScale = scale;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setMaximum(double maximum)
|
||||
{
|
||||
if (IS_FP_SAME(max, maximum))
|
||||
|
@ -67,6 +74,7 @@ DiveCartesianAxis::DiveCartesianAxis() : QObject(),
|
|||
min(0),
|
||||
max(0),
|
||||
interval(1),
|
||||
labelScale(1.0),
|
||||
tick_size(0),
|
||||
textVisibility(true)
|
||||
{
|
||||
|
@ -164,7 +172,7 @@ void DiveCartesianAxis::updateTicks()
|
|||
label->setText(textForValue(currValue));
|
||||
label->setBrush(QBrush(textColor));
|
||||
label->setBrush(colorForValue(currValue));
|
||||
label->setScale(0.8);
|
||||
label->setScale(fontLabelScale());
|
||||
labels.push_back(label);
|
||||
if (orientation == RightToLeft || orientation == LeftToRight) {
|
||||
label->setAlignment(Qt::AlignBottom | Qt::AlignHCenter);
|
||||
|
@ -262,6 +270,11 @@ double DiveCartesianAxis::minimum() const
|
|||
return min;
|
||||
}
|
||||
|
||||
double DiveCartesianAxis::fontLabelScale() const
|
||||
{
|
||||
return labelScale;
|
||||
}
|
||||
|
||||
void DiveCartesianAxis::setColor(const QColor& color)
|
||||
{
|
||||
QPen defaultPen(color);
|
||||
|
|
|
@ -19,16 +19,18 @@ public:
|
|||
enum Orientation{TopToBottom, BottomToTop, LeftToRight, RightToLeft};
|
||||
DiveCartesianAxis();
|
||||
virtual ~DiveCartesianAxis();
|
||||
void setup(double minimum, double maximum, double interval, Orientation o, qreal tickSize, const QPointF& pos);
|
||||
void setup(double minimum, double maximum, double interval, double labelFontScale, Orientation o, qreal tickSize, const QPointF& pos);
|
||||
void setMinimum(double minimum);
|
||||
void setMaximum(double maximum);
|
||||
void setTickInterval(double interval);
|
||||
void setOrientation(Orientation orientation);
|
||||
void setTickSize(qreal size);
|
||||
void setFontLabelScale(qreal scale);
|
||||
double minimum() const;
|
||||
double maximum() const;
|
||||
double tickInterval() const;
|
||||
double tickSize() const;
|
||||
double fontLabelScale() const;
|
||||
qreal valueAt(const QPointF& p) const;
|
||||
qreal percentAt(const QPointF& p);
|
||||
qreal posAtValue(qreal value);
|
||||
|
@ -54,6 +56,7 @@ protected:
|
|||
double tick_size;
|
||||
QColor textColor;
|
||||
bool textVisibility;
|
||||
double labelScale;
|
||||
};
|
||||
|
||||
class DepthAxis : public DiveCartesianAxis {
|
||||
|
|
|
@ -132,6 +132,7 @@ void ProfileWidget2::setupItemOnScene()
|
|||
gasYAxis->setTickSize(1);
|
||||
gasYAxis->setMinimum(0);
|
||||
gasYAxis->setModel(dataModel);
|
||||
gasYAxis->setFontLabelScale(0.7);
|
||||
|
||||
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
|
||||
temperatureAxis->setTickSize(2);
|
||||
|
|
Loading…
Add table
Reference in a new issue