Exemplo n.º 1
0
void DiskAnalizer::paintEvent(QPaintEvent *e)
{
 	QWidget::paintEvent(e);
 	QPainter painter;

 	double bytesFree = getFreeSpace(drive);
	ui.lblBytesFree->setText(QString::number(bytesFree,'f',0));
	double gbFree=(bytesFree/1048576)/1024;
	ui.lblGBFree->setText(QString::number(gbFree,'f',2));
 	double bytesUsed = getUsedSpace(drive);
	ui.lblBytesUsed->setText(QString::number(bytesUsed,'f',0));
	double gbUsed=(bytesUsed/1048576)/1024;
	ui.lblGBUsed->setText(QString::number(gbUsed,'f',2));
	double bytesTotal = getTotalSpace(drive);
 	
	float p =((bytesFree*100)/bytesTotal);

  	painter.begin(this);
  	Nightcharts PieChart;
  	PieChart.setType(Nightcharts::Pie);//{Histogramm,Pie,Dpie};
  	PieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical}
  	PieChart.setCords(ui.widget->geometry().x(),ui.widget->geometry().y(),ui.widget->width(),ui.widget->height());
  
  	PieChart.addPiece("Free Space",Qt::green,p);
  	PieChart.addPiece("Used Space",QColor(200,10,50),100);
  
  	PieChart.draw(&painter);
}
Exemplo n.º 2
0
void PieChart::paintEvent(QPaintEvent *e)
{
    double portion;
    QWidget::paintEvent(e);
        QPainter painter;
        painter.begin(this);
        Nightcharts PieChart;
        PieChart.setType(Nightcharts::Pie);
        PieChart.setLegendType(Nightcharts::Round);
        PieChart.setCords(200,200,this->width()/1.5,this->height()/1.5);


        double sum =0;
        for(int i =0; i<valsLength;i++){
            sum = sum + *vals;
            vals++;
        }

        vals-=valsLength;

        for(int i =0; i<valsLength;i++){
            QColor color;
            if(i==0){
             color = QColor("Green");

            }else if(i==1){
                 color = QColor("Blue");

            }else if(i==2){
             color = QColor("Orange");

            }else if(i==3){
             color = QColor("Red");

            } else if(i==4){
             color = QColor("Purple");

            }else{
                color = QColor("Green");
            }


            portion = *vals / sum;
            portion *= 100;
            PieChart.addPiece(*labs,color,portion);
            vals++;
            labs++;
        }

        vals-=valsLength;
        labs-=valsLength;

        PieChart.draw(&painter);
        PieChart.drawLegend(&painter);
}
Exemplo n.º 3
0
void Dialog::on_pushButton_clicked()
{
    pix = QPixmap(ui->label->width(),ui->label->height());
    pix.fill(colr);//(Qt::white);//
    QPainter painter(&pix);

    Nightcharts PieChart;

    PieChart.setType(Nightcharts::Dpie);//{Histogramm,Pie,Dpie};
    PieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical,Horizontal}
    PieChart.setCords(120,50,ui->label->width()/2,ui->label->height()/3);
    PieChart.addPiece("المجموع العام السنوي",QColor(150,10,50),44);
    PieChart.addPiece("علي",Qt::green,27);
    PieChart.addPiece("كمال",Qt::cyan,4);
    PieChart.addPiece("عمر",Qt::yellow,7);
    PieChart.addPiece("ابو بكر",Qt::blue,4);
    PieChart.addPiece("طلحة",Qt::red,14);
    //PieChart.setShadows(false);
    PieChart.draw(&painter);
    PieChart.drawLegend(&painter);
    damj();
}
Exemplo n.º 4
0
void YearStatistic::paintEvent(QPaintEvent*) {
  QPainter painter;
  painter.begin(this);
  Nightcharts PieChart;
  PieChart.setType(Nightcharts::Histogramm);//{Histogramm,Pie,DPie};
  PieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical}
  PieChart.setCords(10, 10, 250, 280);

  QSqlQuery query;
  query.exec("SELECT au_birth_year, COUNT(*) FROM authors WHERE au_birth_year IS NOT NULL GROUP BY au_birth_year;");
  int total = 0;
  while(query.next()) {
    total += query.value(1).toInt();
  }
  if (query.first()) do {
    PieChart.addPiece(query.value(0).toString(), Qt::lightGray, 10000*query.value(1).toInt()/total*0.01);
  } while(query.next());

  PieChart.draw(&painter);
  PieChart.drawLegend(&painter);
  painter.end();
}
void StatisticaMonetePerMetallo::paintEvent(QPaintEvent* e)
{
    Q_UNUSED(e);

    QPainter painter;
    painter.begin(this);
    Nightcharts pieChart;
    pieChart.setType(Nightcharts::Dpie);//{Histogramm,Pie,DPie};
    pieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical}
    pieChart.setCords(100,100,this->width()/1.5,this->height()/1.5);

    QMap<QString, int> dati;
    float totale = 0.0;

    QList<QString> idmonete = CollezioneXml::getInstance()->getAllId();
    foreach (QString id, idmonete) {
        MonetaXml* m = CollezioneXml::getInstance()->getMoneta(id);
        QString key = QString::fromStdWString(m->getDom()->datiFisici().metallo());
        if (dati.contains(key))
            dati[key]++;
        else
            dati[key] = 1;
        totale++;
    }
Exemplo n.º 6
0
void CPieChartWidget::paintEvent(QPaintEvent * e)
{
    QWidget::paintEvent(e);
    QPainter painter(this);
    QFont font;
    Nightcharts PieChart;
    PieChart.setType(Nightcharts::Dpie);//{Histogramm,Pie,DPie};
    PieChart.setLegendType(Nightcharts::Vertical);//{Round,Vertical}
    PieChart.setCords(10,10,this->width()/1.7,this->height()/1.5);

    std::list <PieElement>::const_iterator cit = m_list_pie_element.begin();
    int count = 0;
    if (m_list_pie_element.empty())
    {
        return;
    }
     int index = 0;
    for ( ; cit != m_list_pie_element.end (); ++cit)
    {
        QColor color = Qt::green;
        ++index;
       
        if (index == 1)
        {
            color = QColor(200,10,50);
        }
        if (index == 2)
        {
            color = Qt::green;
        }
        if (index == 3)
        {
            color = Qt::cyan;
        }
        if (index == 4)
        {
            color = Qt::yellow;
        }
        if (index == 5)
        {
            color = Qt::blue;
        }
        if (index == 6)
        {
            color = Qt::darkCyan;
        }
        if (index == 7)
        {
            color = Qt::color1;
        }
        if (index == 8)
        {
            color = Qt::lightGray;
        }
        if (index == 9)
        {
            color = Qt::darkMagenta;
        }

        if (index == 10)
        {
            color = Qt::darkYellow;
        }



        PieChart.addPiece(cit->name.c_str(), color, cit->data);
    }

  /*PieChart.addPiece("Item1",QColor(200,10,50),34);
    PieChart.addPiece("Item2",Qt::green,27);
    PieChart.addPiece("Item3",Qt::cyan,14);
    PieChart.addPiece("Item4",Qt::yellow,7);
    PieChart.addPiece("Item5",Qt::blue,4);*/
    PieChart.draw(&painter);
    PieChart.drawLegend(&painter);
}