// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenRDFWidget::on_generateRDFBtn_clicked() { QLocale loc = QLocale::system(); // Generate the ODF Data from the current values in the ODFTableModel bool ok = false; float minDist = loc.toFloat(minDistLE->text(), &ok); float maxDist = loc.toFloat(maxDistLE->text(), &ok); int numBins = numBinsLE->text().toInt(&ok); std::vector<float> boxDims(3); boxDims[0] = loc.toFloat(BoxSizeXLE->text(), &ok); boxDims[1] = loc.toFloat(BoxSizeYLE->text(), &ok); boxDims[2] = loc.toFloat(BoxSizeZLE->text(), &ok); std::vector<float> boxRes(3); boxRes[0] = 0.1f; boxRes[1] = 0.1f; boxRes[2] = 0.1f; // Generate the RDF Frequencies std::vector<float> rdfFrequencies = RadialDistributionFunction::GenerateRandomDistribution(minDist, maxDist, numBins, boxDims, boxRes); QVector<float> qFreq = QVector<float>::fromStdVector(rdfFrequencies); // Update the Table model with the latest values m_RDFTableModel->setTableData(qFreq); // Update the Qwt plot with the correct values updateRDFPlot(qFreq); emit rdfParametersChanged(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int PrecipitatePhaseWidget::gatherSizeDistributionFromGui(float& mu, float& sigma, float& minCutOff, float& maxCutOff, float& stepSize) { QLocale loc = QLocale::system(); bool ok = false; mu = loc.toFloat(m_Mu_SizeDistribution->text(), &ok); if (ok == false) { return 0; } sigma = loc.toFloat(m_Sigma_SizeDistribution->text(), &ok); if (ok == false) { return 0; } minCutOff = loc.toFloat(m_MinSigmaCutOff->text(), &ok); if (ok == false) { return 0; } maxCutOff = loc.toFloat(m_MaxSigmaCutOff->text(), &ok); if (ok == false) { return 0; } stepSize = loc.toFloat(m_BinStepSize->text(), &ok); if (ok == false) { return 0; } return 1; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void FloatVec3Widget::filterNeedsInputParameters(AbstractFilter* filter) { bool ok = false; FloatVec3_t defValue = m_FilterParameter->getDefaultValue().value<FloatVec3_t>(); FloatVec3_t data; QLocale loc; data.x = loc.toFloat(xData->text(), &ok); if(!ok) { errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);")); errorLabel->setText("X Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); DREAM3DStyles::LineEditErrorStyle(xData); data.x = defValue.x; } data.y = loc.toFloat(yData->text(), &ok); if(!ok) { errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);")); errorLabel->setText("Y Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); DREAM3DStyles::LineEditErrorStyle(xData); data.y = defValue.y; } data.z = loc.toFloat(zData->text(), &ok); if(!ok) { errorLabel->setStyleSheet(QString::fromLatin1("color: rgb(255, 0, 0);")); errorLabel->setText("Z Value entered is beyond the representable range for a double.\nThe filter will use the default value of " + getFilterParameter()->getDefaultValue().toString()); errorLabel->show(); DREAM3DStyles::LineEditErrorStyle(zData); data.z = defValue.z; } QVariant v; v.setValue(data); ok = filter->setProperty(PROPERTY_NAME_AS_CHAR, v); if(false == ok) { FilterParameterWidgetsDialogs::ShowCouldNotSetFilterParameter(getFilter(), getFilterParameter()); } }
void Plot::paste() { QLocale l; QClipboard *clipboard = QApplication::clipboard(); QString text = clipboard->text(); if(!text.isEmpty()) { QList<QString> items = text.split('\n'); QList<float> values; for(int i = 0; i < items.count(); i++) { values.append(l.toFloat(items[i])); } this->detachItems(); // Insert new curves curve = new QwtPlotCurve( "y = sin(x)" ); curve->setRenderHint( QwtPlotItem::RenderAntialiased ); curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true ); curve->setPen( Qt::red ); curve->attach( this ); Data* data = new Data(&values); curve->setData(data); setAxisScale( yLeft, data->yMin, data->yMax); setAxisScale( xBottom, data->xMin, data->xMax); QwtPlotGrid* grid = new QwtPlotGrid(); grid->setPen(Qt::black, 0.1, Qt::DashLine); grid->attach(this); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- float EditPhaseDialog::getPhaseFraction() { bool ok = false; QLocale loc = QLocale::system(); float d = loc.toFloat(phaseFraction->text(), &ok); if (ok) { return d; } return -1.0; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void EditPhaseDialog::on_phaseFraction_textChanged(const QString& string) { bool ok = false; QLocale loc = QLocale::system(); float d = loc.toFloat(phaseFraction->text(), &ok); if (ok) { float total = d + m_OtherPhaseFractions; total = d / total; calcPhaseFraction->setText(QString::number(total)); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void StatsGenRDFWidget::updateRDFPlot(QVector<float>& freqs) { // These are the output vectors QwtArray<double> xD(static_cast<int>(freqs.size())); QwtArray<double> yD(static_cast<int>(freqs.size())); QLocale loc = QLocale::system(); bool ok = false; float minDist = loc.toFloat(minDistLE->text(), &ok); float maxDist = loc.toFloat(maxDistLE->text(), &ok); const int numValues = freqs.size(); float increment = (maxDist - minDist) / numValues; double pos = minDist; for (qint32 i = 0; i < numValues; ++i) { xD[i] = pos; yD[i] = static_cast<double>(freqs.at(i)); pos = pos + increment; } // This will actually plot the XY data in the Qwt plot widget QwtPlotCurve* curve = m_PlotCurve; #if QWT_VERSION >= 0x060000 curve->setSamples(xD, yD); #else curve->setData(xD, yD); #endif curve->setStyle(QwtPlotCurve::Lines); //Use Antialiasing to improve plot render quality curve->setRenderHint( QwtPlotItem::RenderAntialiased, true ); QPen pen; pen.setColor(Qt::white); pen.setWidth(2); curve->setPen(pen);//Set colour and thickness for drawing the curve curve->attach(m_RDFPlot); m_RDFPlot->replot(); }