void keyPressEvent(QKeyEvent* event) { if(!image) { QWidget::keyPressEvent(event); return; } switch(event->key()) { case Qt::Key_PageUp: case Qt::Key_Plus: event->accept(); changeScale(0.1f); update(); break; case Qt::Key_PageDown: case Qt::Key_Minus: event->accept(); changeScale(-0.1f); update(); break; default: QWidget::keyPressEvent(event); break; } }
void Spectro::on_btnOkScale_clicked() { changeScale(ui->edtXmin->text().toFloat(), ui->edtXmax->text().toFloat(), ui->edtYmin->text().toFloat(), ui->edtYmax->text().toFloat()); }
PathBlock* PathBlock::scale(float scaleX, float scaleY) { changeScale(scaleX, scaleY); resetTransform(); return this; }
void wheelEvent(QWheelEvent* event) { QWidget::wheelEvent(event); if(!image) return; changeScale(0.1 * event->delta() / 160); update(); }
Graphic::Graphic() : m_circles{sf::CircleShape{300, 60}, sf::CircleShape{200, 60}, sf::CircleShape{100, 60}}, m_font{}, m_distances() { m_circles[0].setPosition(10, 10); m_circles[1].setPosition(110, 110); m_circles[2].setPosition(210, 210); for (auto& elem : m_circles) { elem.setFillColor(sf::Color::Transparent); elem.setOutlineColor(sf::Color::White); elem.setOutlineThickness(1); } m_font.loadFromFile("/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"); changeScale(c_maxDistance); }
void ImageBuilder::convertTemperatureToPalette(unsigned short* src, unsigned char* dst, EOptrisColoringPalette palette) { unsigned int i=0; unsigned int j=0; int dIdx=0; int sIdx=0; if(_dynamicScale==true) { _min = USHRT_MAX; _max = 0; for(i = 0; i < _size; i++) { unsigned short pixel = src[i]; if(pixel > _max) _max = pixel; if(pixel < _min) _min = pixel; } } unsigned int offs = (_stride - _width) * 3; for(j = 0; j < _height; j++) { for(i = 0; i < _width; i++) { unsigned int idx = changeScale(src[sIdx++], _min, _max, 0, 239); switch (palette) { default: case eIron: dst[dIdx++] = Iron[idx][0]; dst[dIdx++] = Iron[idx][1]; dst[dIdx++] = Iron[idx][2]; break; case eBlackWhite: dst[dIdx++] = BlackWhite[idx][0]; dst[dIdx++] = BlackWhite[idx][1]; dst[dIdx++] = BlackWhite[idx][2]; break; }; } dIdx += offs; } }
int main(int argc, char* argv[]) { double x[] = {60, 65, 70, 65, 66, 68, 69, 62, 65, 66, 68, 59, 60, 64, 66, 68, 59, 60, 64, 60, 64, 66, 68, 59, 60, 64, 59, 60, 64, 66, 69, 67}; double y[32]; int N = sizeof(x)/sizeof(double); int m = 4; for(int scale=1;scale<20;scale++) { int len_y = changeScale(x, y, N, scale); if(len_y <= m) break; for(int i=0;i<len_y;i++) printf("%f ", y[i]); double mse = MSE(y, len_y, m); printf("\n--------------------------------------------------------\n"); printf("%f\n\n\n", mse); } return 0; }
/*! Reimplemets the QGraphicsView::wheelEvent() */ void SchematicSceneViewer::wheelEvent(QWheelEvent *me) { me->accept(); double factor = exp(me->delta() * 0.001); changeScale(me->pos(), factor); }
//using namespace cv; Spectro::Spectro(QWidget *parent) : QMainWindow(parent), ui(new Ui::Spectro) { ui->setupUi(this); divData = false; calibration = false; colors.append(Qt::black); colors.append(Qt::red); colors.append(Qt::darkGreen); colors.append(Qt::darkRed); colors.append(Qt::blue); colors.append(Qt::darkCyan); colors.append(Qt::darkMagenta); colors.append(Qt::darkYellow); colors.append(Qt::darkBlue); currentColor = 0; ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWidgetScale)); ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWidgetMaths)); ui->tabWidget->removeTab(ui->tabWidget->indexOf(ui->tabWidgetCalib)); ui->tabWidget->hide(); spectro = new Spectrometer(1); QSettings settings; setCalibEnabled(true); /* if(!settings.value("calibration/focal").isNull()){ double focal = settings.value("calibration/focal").toDouble(); double sin_i = settings.value("calibration/sin_i").toDouble(); double pas = settings.value("calibration/pas").toDouble(); spectro->setParameters(focal,sin_i,pas); ui->tabWidgetCalib->setEnabled(false); if(spectro->isWlCalib()) setCalibEnabled(false); } */ readCalibrationList(); if(!settings.value("calibration_num",0).isNull()){ int num = settings.value("calibration_num").toInt(); qDebug()<<"num : "<<num; if((num>=0) && (num <calibrationList.size())){ qDebug()<<"calibrating"; Calibration cal = calibrationList[num]; spectro->setParameters(cal.focal,cal.sin_i,1e3); ui->tabWidgetCalib->setEnabled(false); if(spectro->isWlCalib()) setCalibEnabled(false); } } lastDir = settings.value("application/fileDir",QApplication::applicationDirPath()).toString(); if(!settings.value("spectro/x1").isNull()){ double x1 = settings.value("spectro/x1").toInt(); double y1 = settings.value("spectro/y1").toInt(); double x2 = settings.value("spectro/x2").toInt(); double y2 = settings.value("spectro/y2").toInt(); setSpectrumRect(QRect(QPoint(x1,y1),QPoint(x2,y2)).normalized()); } if(!spectro->isOk()) close(); //connect(&video,SIGNAL(rectSelected(QRect)),spectro,SLOT(setSpectrumRect(QRect))); connect(&video,SIGNAL(rectSelected(QRect)),this,SLOT(setSpectrumRect(QRect))); connect(spectro,SIGNAL(newSpectrum(Tjcampdx)),this,SLOT(newSpectrum(Tjcampdx))); //connect(spectro,SIGNAL(newSpectrum_rgb(Tjcampdx,Tjcampdx,Tjcampdx)),this,SLOT(newSpectrum_rgb(Tjcampdx,Tjcampdx,Tjcampdx))); connect(spectro,SIGNAL(saturation()),this,SLOT(spectroSaturation())); connect(spectro,SIGNAL(measureFinished(Tjcampdx)),this,SLOT(newMeasure(Tjcampdx))); connect(spectro,SIGNAL(measureProgressed(int)),ui->progressMeasure,SLOT(setValue(int))); connect(spectro,SIGNAL(newFrame(QImage*)),&video,SLOT(setImage(QImage*))); connect(ui->plot->xAxis,SIGNAL(rangeChanged(QCPRange)),this,SLOT(xScaleChanged(QCPRange))); connect(ui->plot->yAxis,SIGNAL(rangeChanged(QCPRange)),this,SLOT(yScaleChanged(QCPRange))); connect(ui->actionShowVideo,SIGNAL(toggled(bool)),&video,SLOT(setVisible(bool))); connect(ui->plot,SIGNAL(mousePress(QMouseEvent*)),this,SLOT(plotClicked(QMouseEvent*))); connect(qApp,SIGNAL(focusChanged(QWidget*,QWidget*)),this,SLOT(focusChanged(QWidget*,QWidget*))); // graph for live spectrum liveSpec = ui->plot->addGraph(); /* liveSpecR = ui->plot->addGraph(); liveSpecR->setPen(QPen(Qt::red)); liveSpecR->setVisible(false); liveSpecG = ui->plot->addGraph(); liveSpecG->setPen(QPen(Qt::green)); liveSpecG->setVisible(false); liveSpecB = ui->plot->addGraph(); liveSpecB->setPen(QPen(Qt::blue)); liveSpecB->setVisible(false); */ bbSpec = ui->plot->addGraph(); bbSpec->setPen(QPen(Qt::black)); bbSpec->setVisible(false); wlLine = new QCPItemStraightLine(ui->plot); ui->plot->addItem(wlLine); wlLine->setPen(QPen(Qt::red)); // add the text label at the top: wlLabel = new QCPItemText(ui->plot); ui->plot->addItem(wlLabel); wlLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignRight); wlLabel->setClipToAxisRect(false); wlLabel->position->setType(QCPItemPosition::ptAxisRectRatio); wlLabel->position->setCoords(1, 0); // place position at right/top of axis rect wlLabel->setText("\u03BB = ??? nm"); connect(ui->plot,SIGNAL(mouseMove(QMouseEvent*)),this,SLOT(plotMouseMoved(QMouseEvent*))); if(!settings.value("scale/xmin").isNull()){ double xmin = settings.value("scale/xmin",400).toDouble(); double xmax = settings.value("scale/xmax",1000).toDouble(); double ymin = settings.value("scale/ymin",0).toDouble(); double ymax = settings.value("scale/ymax",700).toDouble(); changeScale(xmin,xmax,ymin,ymax); } ui->spinNMeas->setValue(settings.value("application/nAverage",1).toInt()); ui->spinRepeat->setValue(settings.value("application/nRepeat",1).toInt()); ui->sldGain->setValue(settings.value("spectro/gain",0).toInt()); spectro->setGain(ui->sldGain->value()/100.); /* QFileInfo gainFile = QFileInfo(QFileInfo(settings.fileName()).absolutePath()+ QString("dark_g%1.dx").arg(ui->sldGain->value())); if(gainFile.exists()) { Tjcampdx darkSpec; darkSpec.Open(gainFile.absoluteFilePath().toStdString()); spectro->setDarkSpec(darkSpec); } */ spectro->setFrameRate(15); video.hide(); }