/** Overloads default QWidget::paintEvent. Draws the actual * bandwidth graph. */ void RSGraphWidget::paintEvent(QPaintEvent *) { //std::cerr << "In paint event!" << std::endl; /* Set current graph dimensions */ _rec = this->frameRect(); /* Start the painter */ _painter->begin(this); /* We want antialiased lines and text */ _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); /* Fill in the background */ _painter->fillRect(_rec, QBrush(BACK_COLOR)); _painter->drawRect(_rec); /* Paint the scale */ paintScale1(); /* Plot the rsDHT/allDHT data */ paintData(); /* Paint the rsDHT/allDHT totals */ paintTotals(); // part of the scale that needs to write over the data curves. paintScale2(); if(_flags & RSGRAPH_FLAGS_SHOW_LEGEND) paintLegend() ; /* Stop the painter */ _painter->end(); }
/** Overloads default QWidget::paintEvent. Draws the actual * bandwidth graph. */ void GraphFrame::paintEvent(QPaintEvent *event) { Q_UNUSED(event); /* Set current graph dimensions */ _rec = this->frameRect(); /* Start the painter */ _painter->begin(this); /* We want antialiased lines and text */ _painter->setRenderHint(QPainter::Antialiasing); _painter->setRenderHint(QPainter::TextAntialiasing); /* Fill in the background */ _painter->fillRect(_rec, QBrush(BACK_COLOR)); _painter->drawRect(_rec); /* Paint the scale */ paintScale(); /* Plot the send/receive data */ paintData(); /* Paint the send/recv totals */ paintTotals(); /* Stop the painter */ _painter->end(); }
void ComediScope::paintEvent( QPaintEvent * ) { int ret; while (1) { // we need data in all the comedi devices for(int n=0;n<nComediDevices;n++) { if (!comedi_get_buffer_contents(dev[n],subdevice)) return; } for(int n=0;n<nComediDevices;n++) { int subdev_flags = comedi_get_subdevice_flags(dev[n], subdevice); int bytes_per_sample; if(subdev_flags & SDF_LSAMPL) { bytes_per_sample = sizeof(lsampl_t); } else { bytes_per_sample = sizeof(sampl_t); } unsigned char buffer[bytes_per_sample*channels_in_use]; ret = read(comedi_fileno(dev[n]), buffer, bytes_per_sample*channels_in_use); if (ret==0) { printf("BUG! No data in buffer.\n"); exit(1); } if (ret<0) { printf("\n\nError %d during read! Exiting.\n\n",ret); exit(1); } for(int i=0;i<channels_in_use;i++) { int sample; if (comediRecord->channel[n][i]->isActive()) { int ch = comediRecord->channel[n][i]->getChannel(); if(subdev_flags & SDF_LSAMPL) { sample = ((int)((lsampl_t *)buffer)[ch]); } else { sample = ((int)((sampl_t *)buffer)[ch]); } // store raw data daqData[n][i] = sample; // convert data to physical units for plotting float value = comedi_to_phys(sample, crange[n], maxdata[n]); // filtering value = comediRecord->dcSub[n][i]->filter(value); value = comediRecord->hp[n][i]->filter(value); value = comediRecord->lp[n][i]->filter(value); // remove 50Hz if (comediRecord->filterCheckbox->checkState()==Qt::Checked) { value=iirnotch[n][i]->filter(value); } if ((n==fftdevno) && (ch==fftch) && (comediRecord->fftscope)) comediRecord->fftscope->append(value); // average response if TB is slower than sampling rate adAvgBuffer[n][i] = adAvgBuffer[n][i] + value; } } } // save data if (comediRecord->recPushButton->checkState()==Qt::Checked) { writeFile(); } nsamples++; tb_counter--; // enough averaged? if (tb_counter<=0) { for(int n=0;n<nComediDevices;n++) { for(int i=0;i<channels_in_use;i++) { adAvgBuffer[n][i]=adAvgBuffer[n][i]/tb_init; } } // plot the stuff paintData(adAvgBuffer); // clear buffer tb_counter=tb_init; for(int n=0;n<nComediDevices;n++) { for(int i=0;i<channels_in_use;i++) { adAvgBuffer[n][i]=0; } } } } }