void SpotSelectTool::updateIndices(const QPoint &pos) { currentPos = pos; int mX = pos.x(); int mY = pos.y(); int nx = imageHeader->nx(); int ny = imageHeader->ny(); float ratio = (float)(ny) / (((float)(nx-1))*2) ; float xScale = imageHeader->mx() / imageHeader->cellA(); float yScale = imageHeader->my() / imageHeader->cellB(); if (imageHeader->isFFT()) { QStringList cell = projectData.parameterData(QDir(workingDir))->getValue("lattice").split(','); float lattice[2][2]; if(cell.size() > 3) { lattice[0][0] = cell[0].toFloat(); lattice[1][0] = cell[1].toFloat(); lattice[0][1] = cell[2].toFloat(); lattice[1][1] = cell[3].toFloat(); } else { lattice[0][0] = 0; lattice[1][0] = 0; lattice[0][1] = 0; lattice[1][1] = 0; } float det = lattice[0][0] * lattice[1][1] - lattice[0][1] * lattice[1][0]; if (det != 0) { inv[0][0] = lattice[1][1] / det; inv[1][1] = lattice[0][0] / det; inv[0][1] = -lattice[0][1] / det; inv[1][0] = -lattice[1][0] / det; } float x = ((float) (pos.x()) * inv[0][0] + (float) (pos.y()) * inv[0][1]); float y = ((float) (pos.x()) * inv[1][0] + (float) (pos.y()) * inv[1][1]); if (x < 0.0) x -= 0.5; else x += 0.5; if (y < 0.0) y -= 0.5; else y += 0.5; i->setText(QString::number(int(x))); j->setText(QString::number(int(y))); ParametersConfiguration* data = projectData.parameterData(QDir(workingDir)); // resolution->setText(QString::number(((imageHeader->ny()) * data->getValue("stepdigitizer").toFloat()*1e4 / data->getValue("magnification").toFloat()) / (sqrt(float(xScale * xScale * mX * mX + yScale * yScale * mY * mY))))); resolution->setText(QString::number((imageHeader->ny()) / (sqrt(float(xScale * xScale * mX * mX * (ratio * ratio) + yScale * yScale * mY * mY))))); mouseX->setText(QString::number(mX)); mouseY->setText(QString::number(mY)); QPoint p = pos; float phaseValue; if (p.x() < 0) { p *= -1; phaseValue = 2.0 * PI - imageData->phase(QPoint(p.x(), p.y() + screenHeight / 2)); } else phaseValue = imageData->phase(QPoint(p.x(), p.y() + screenHeight / 2)); value->setText(QString::number(imageData->value(QPoint(p.x(), p.y() + screenHeight / 2)))); phase->setText(QString::number(phaseValue / (2.0 * PI)*360.0)); emit phaseChanged(phaseValue); } else { float xPos = pos.x() + screenWidth / 2; float yPos = (pos.y() + (screenHeight) / 2); float scale = image->imageScale(); float cellC = ((float*) (imageHeader->rawData()))[15]; int mode = imageHeader->mode(); QMatrix m = imageData->matrix(); // qDebug()<<m.m11()<<" "<<m.m22()<<endl; if (mode < 3) { m = m.inverted(); QPointF tP = QPointF(pos.x() * m.m11() - pos.y() * m.m21(), -(pos.x() * m.m12() - pos.y() * m.m22())) * scale + QPointF(screenWidth / 2, screenHeight / 2); xPos = (int) tP.x(); yPos = (int) tP.y(); } if (xPos < 0) xPos = 0; if (xPos > screenWidth - 1) xPos = screenWidth - 1; if (yPos < 0) yPos = 0; if (yPos > screenHeight - 1) yPos = screenHeight - 1; value->setText(QString::number(imageData->value(QPoint(xPos, yPos)))); if (cellC != 0 && cellC != 90 && mode < 3) { // xPos = (xPos/(float)image->width()*2-1)*360; // yPos = (yPos/(float)image->height()*2-1)*360; } mouseX->setText(QString::number(xPos + 1)); mouseY->setText(QString::number(yPos + 1)); } }
void Community::update() { while (phaseChanged()) reUpdatePlants(); }