-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlegendwindow.cpp
32 lines (30 loc) · 1003 Bytes
/
legendwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include "legendwindow.h"
#include "ui_legendwindow.h"
LegendWindow::LegendWindow(QWidget *parent) :
QWidget(parent),
ui(new Ui::legendwindow)
{
ui->setupUi(this);
legendView = new QGraphicsView(this);
}
LegendWindow::~LegendWindow()
{
delete ui;
}
void LegendWindow::updateview(double max, double min){
QGraphicsScene *scene = new QGraphicsScene();
scene->setSceneRect(0,0,70,80);
legendView->setScene(scene);
QLinearGradient linear(QPoint(5,15),QPoint(5,65));
linear.setColorAt(0,Qt::white);
linear.setColorAt(1,Qt::black);
linear.setSpread(QGradient::PadSpread);
scene->addRect(5,15,10,50,QPen(QColor(255,255,255),0),linear);
//std::ostringstream maxss;
int precision = 0;
if(max-min<10) precision = 2;
QGraphicsTextItem *minLabel = scene->addText(QString::number(min,'f',precision));
minLabel->setPos(15,50);
QGraphicsTextItem *maxLabel = scene->addText(QString::number(max,'f',precision));
maxLabel->setPos(15,0);
}