mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use the same profile colors on the planer for the Time and Depth
Use the same profile colors on the planner for the Time and Depth rulers. this needed a new method on the rulers - setColor, that will call the setPen method and make everything behave properly. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
43664d7cd5
commit
23b29bd3cd
2 changed files with 22 additions and 6 deletions
|
@ -56,6 +56,7 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
);
|
);
|
||||||
timeLine->setOrientation(Qt::Horizontal);
|
timeLine->setOrientation(Qt::Horizontal);
|
||||||
timeLine->setTickSize(fromPercent(1, Qt::Vertical));
|
timeLine->setTickSize(fromPercent(1, Qt::Vertical));
|
||||||
|
timeLine->setColor(profile_color[TIME_GRID].at(0));
|
||||||
timeLine->updateTicks();
|
timeLine->updateTicks();
|
||||||
scene()->addItem(timeLine);
|
scene()->addItem(timeLine);
|
||||||
|
|
||||||
|
@ -63,16 +64,15 @@ DivePlannerGraphics::DivePlannerGraphics(QWidget* parent): QGraphicsView(parent)
|
||||||
depthLine->setMinimum(0);
|
depthLine->setMinimum(0);
|
||||||
depthLine->setMaximum(40);
|
depthLine->setMaximum(40);
|
||||||
depthLine->setTickInterval(10);
|
depthLine->setTickInterval(10);
|
||||||
|
|
||||||
depthLine->setLine(
|
depthLine->setLine(
|
||||||
fromPercent(10, Qt::Horizontal),
|
fromPercent(10, Qt::Horizontal),
|
||||||
fromPercent(10, Qt::Vertical),
|
fromPercent(10, Qt::Vertical),
|
||||||
fromPercent(10, Qt::Horizontal),
|
fromPercent(10, Qt::Horizontal),
|
||||||
fromPercent(90, Qt::Vertical)
|
fromPercent(90, Qt::Vertical)
|
||||||
);
|
);
|
||||||
|
|
||||||
depthLine->setOrientation(Qt::Vertical);
|
depthLine->setOrientation(Qt::Vertical);
|
||||||
depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
|
depthLine->setTickSize(fromPercent(1, Qt::Horizontal));
|
||||||
|
depthLine->setColor(profile_color[DEPTH_GRID].at(0));
|
||||||
depthLine->updateTicks();
|
depthLine->updateTicks();
|
||||||
scene()->addItem(depthLine);
|
scene()->addItem(depthLine);
|
||||||
|
|
||||||
|
@ -405,22 +405,32 @@ void Ruler::updateTicks()
|
||||||
qDeleteAll(ticks);
|
qDeleteAll(ticks);
|
||||||
ticks.clear();
|
ticks.clear();
|
||||||
QLineF m = line();
|
QLineF m = line();
|
||||||
|
QGraphicsLineItem *item = NULL;
|
||||||
|
|
||||||
if (orientation == Qt::Horizontal) {
|
if (orientation == Qt::Horizontal) {
|
||||||
double steps = (max - min) / interval;
|
double steps = (max - min) / interval;
|
||||||
double stepSize = (m.x2() - m.x1()) / steps;
|
double stepSize = (m.x2() - m.x1()) / steps;
|
||||||
qreal pos;
|
qreal pos;
|
||||||
for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) {
|
for (qreal pos = m.x1(); pos < m.x2(); pos += stepSize) {
|
||||||
ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this));
|
item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this);
|
||||||
|
item->setPen(pen());
|
||||||
|
ticks.push_back(item);
|
||||||
}
|
}
|
||||||
ticks.push_back(new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this));
|
item = new QGraphicsLineItem(pos, m.y1(), pos, m.y1() + tickSize, this);
|
||||||
|
item->setPen(pen());
|
||||||
|
ticks.push_back(item);
|
||||||
} else {
|
} else {
|
||||||
double steps = (max - min) / interval;
|
double steps = (max - min) / interval;
|
||||||
double stepSize = (m.y2() - m.y1()) / steps;
|
double stepSize = (m.y2() - m.y1()) / steps;
|
||||||
qreal pos;
|
qreal pos;
|
||||||
for (pos = m.y1(); pos < m.y2(); pos += stepSize) {
|
for (pos = m.y1(); pos < m.y2(); pos += stepSize) {
|
||||||
ticks.push_back(new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this));
|
item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this);
|
||||||
|
item->setPen(pen());
|
||||||
|
ticks.push_back(item);
|
||||||
}
|
}
|
||||||
ticks.push_back(new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this));
|
item = new QGraphicsLineItem(m.x1(), pos, m.x1() - tickSize, pos, this);
|
||||||
|
item->setPen(pen());
|
||||||
|
ticks.push_back(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,6 +479,11 @@ double Ruler::minimum() const
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ruler::setColor(const QColor& color)
|
||||||
|
{
|
||||||
|
setPen(QPen(color));
|
||||||
|
}
|
||||||
|
|
||||||
Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem()
|
Button::Button(QObject* parent): QObject(parent), QGraphicsRectItem()
|
||||||
{
|
{
|
||||||
icon = new QGraphicsPixmapItem(this);
|
icon = new QGraphicsPixmapItem(this);
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
double maximum() const;
|
double maximum() const;
|
||||||
qreal valueAt(const QPointF& p);
|
qreal valueAt(const QPointF& p);
|
||||||
qreal posAtValue(qreal value);
|
qreal posAtValue(qreal value);
|
||||||
|
void setColor(const QColor& color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Orientation orientation;
|
Qt::Orientation orientation;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue