mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fixes positioning of the legend in View and Print modes.
This patch makes a better assumption of the location for the legend in both View and Print modes. It also fixes a few oddities that we used to have ( like hardcoded spacing ). We are taking the scene().sceneRect() now into consideration to better place it on canvas. Fixes: #322 Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
20d924a16e
commit
d3a56c137b
1 changed files with 10 additions and 6 deletions
|
@ -589,7 +589,7 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
setup_pp_limits(&gc);
|
setup_pp_limits(&gc);
|
||||||
QColor c;
|
QColor c;
|
||||||
QPointF from, to;
|
QPointF from, to;
|
||||||
QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - 15);
|
QPointF legendPos = QPointF(scene()->sceneRect().width() * 0.4, scene()->sceneRect().height() - scene()->sceneRect().height()*0.02);
|
||||||
|
|
||||||
if (prefs.pp_graphs.pn2) {
|
if (prefs.pp_graphs.pn2) {
|
||||||
c = getColor(PN2);
|
c = getColor(PN2);
|
||||||
|
@ -669,16 +669,20 @@ void ProfileGraphicsView::plot_pp_gas_profile()
|
||||||
|
|
||||||
void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF& legendPos)
|
void ProfileGraphicsView::createPPLegend(QString title, const QColor& c, QPointF& legendPos)
|
||||||
{
|
{
|
||||||
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, 16, 16);
|
QGraphicsRectItem *rect = new QGraphicsRectItem(0, 0, scene()->sceneRect().width() * 0.01, scene()->sceneRect().width() * 0.01);
|
||||||
rect->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
|
||||||
rect->setBrush(QBrush(c));
|
rect->setBrush(QBrush(c));
|
||||||
rect->setPos(legendPos);
|
rect->setPos(legendPos);
|
||||||
|
rect->setPen(QPen(QColor(Qt::transparent)));
|
||||||
QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(title);
|
QGraphicsSimpleTextItem *text = new QGraphicsSimpleTextItem(title);
|
||||||
text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() - 6);
|
text->setPos(legendPos.x() + rect->boundingRect().width() + 5, legendPos.y() );
|
||||||
text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
|
|
||||||
scene()->addItem(rect);
|
scene()->addItem(rect);
|
||||||
scene()->addItem(text);
|
scene()->addItem(text);
|
||||||
legendPos.setX( legendPos.x() + 100);
|
legendPos.setX(text->pos().x() + text->boundingRect().width() + 20);
|
||||||
|
if(printMode){
|
||||||
|
QFont f = text->font();
|
||||||
|
f.setPointSizeF( f.pointSizeF() * 0.7);
|
||||||
|
text->setFont(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileGraphicsView::plot_deco_text()
|
void ProfileGraphicsView::plot_deco_text()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue