Exemplo n.º 1
0
void Lcd::showValues() {
  showHumidity();
  showTemperature();
  showCo2();
}
Exemplo n.º 2
0
DiagramWidget::DiagramWidget(QWidget *parent) :
    QWidget(parent)
{
    tableWidget=new QTableWidget();
    QStringList list;
    list.append(tr("Type"));
    list.append(tr("Record Date"));
    list.append(tr("Time"));
    list.append(tr("Selected Value"));
    list.append(tr("Unit"));
    list.append(tr("Maximum Value"));
    list.append(tr("Minimum Value"));
    list.append(tr("Average Value"));
    list.append(tr("Upper Limit"));
    list.append(tr("Lower Limit"));
    list.append(tr("Number"));
    tableWidget->setColumnCount(11);
    tableWidget->setRowCount(2);
    tableWidget->setHorizontalHeaderLabels(list);
    tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);

    tableWidget->setItem(0,0,new QTableWidgetItem(tr("Temperature")));
    tableWidget->setItem(1,0,new QTableWidgetItem(tr("Humidity")));
    tableWidget->setItem(0,4,new QTableWidgetItem("°C"));
    tableWidget->setItem(1,4,new QTableWidgetItem("%RH"));

    bigAct=new QAction(QIcon(":/png/png/big"),"",0);
    smallAct=new QAction(QIcon(":/png/png/small"),"",0);
    reductionAct=new QAction(QIcon(":/png/png/back"),"",0);
    radioRB1=new QRadioButton(tr("Temperature+Humidity"));
    radioRB2=new QRadioButton(tr("Temperature"));
    radioRB3=new QRadioButton(tr("Humidity"));
    radioRB1->setChecked(true);
    bigAct->setToolTip(tr("curves zoom out"));
    smallAct->setToolTip(tr("curves zoom in"));
    reductionAct->setText(tr("Rstore"));

    QToolBar *toolBar=new QToolBar();
    toolBar->addSeparator();
    toolBar->addAction(bigAct);
    toolBar->addAction(smallAct);
    toolBar->addAction(reductionAct);
    toolBar->addSeparator();
    toolBar->addWidget(radioRB1);
    toolBar->addWidget(radioRB2);
    toolBar->addWidget(radioRB3);

    customPlot=new QCustomPlot();
    customPlot->legend->setVisible(true);
    customPlot->legend->setIconSize(10,5);
    customPlot->axisRect()->insetLayout()->setInsetAlignment(0, Qt::AlignTop|Qt::AlignLeft);
    customPlot->setInteractions(QCP::iRangeDrag|QCP::iRangeZoom);
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->addGraph();
    customPlot->graph(0)->setName(tr("Temperature"));
    customPlot->graph(1)->setName(tr("Humidity"));
    QPen pen;
    pen.setWidth(2);
    pen.setColor(QColor(0,0,255));
    customPlot->graph(0)->setPen(pen);
    pen.setColor(QColor(0,128,0));
    customPlot->graph(1)->setPen(pen);
    pen.setColor(QColor(128,64,0));
    pen.setWidth(1);
    customPlot->graph(2)->setPen(pen);
    pen.setColor(QColor(255,0,0));
    pen.setStyle(Qt::DashLine);
    customPlot->graph(3)->setPen(pen);
    customPlot->graph(4)->setPen(pen);
    pen.setColor(QColor(255,0,255));
    customPlot->graph(5)->setPen(pen);
    customPlot->graph(6)->setPen(pen);
//    customPlot->graph(2)->setVisible(false);
    customPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
    QString format=QString("%1\n%2").arg(_dateFormat).arg(_timeFormat);
    customPlot->xAxis->setDateTimeFormat(format);
    customPlot->xAxis->setAutoTickStep(false);
    customPlot->legend->removeAt(2);
    customPlot->legend->removeAt(3);
    customPlot->legend->removeAt(4);
    customPlot->legend->removeAt(5);
    customPlot->legend->removeAt(6);

    QVBoxLayout *hLayout=new QVBoxLayout(this);
    hLayout->addWidget(toolBar);
    hLayout->addWidget(customPlot,5);
    hLayout->addWidget(tableWidget,1);


    //信号/槽
    connect(reductionAct,SIGNAL(triggered()),this,SLOT(reduction()));
    connect(customPlot,SIGNAL(mouseMove(QMouseEvent*)),this,SLOT(mousemoved(QMouseEvent*)));
    connect(customPlot,SIGNAL(mousePress(QMouseEvent*)),this,SLOT(mousePress(QMouseEvent*)));
    connect(radioRB1,SIGNAL(clicked()),this,SLOT(showAll()));
    connect(radioRB2,SIGNAL(clicked()),this,SLOT(showTemperature()));
    connect(radioRB3,SIGNAL(clicked()),this,SLOT(showHumidity()));
    connect(bigAct,SIGNAL(triggered()),this,SLOT(bigAct_trogged()));
    connect(smallAct,SIGNAL(triggered()),this,SLOT(smallAct_trogged()));
}