Пример #1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void FloatVec3Widget::setupGui()
{
  // Catch when the filter is about to execute the preflight
  connect(getFilter(), SIGNAL(preflightAboutToExecute()),
          this, SLOT(beforePreflight()));

  // Catch when the filter is finished running the preflight
  connect(getFilter(), SIGNAL(preflightExecuted()),
          this, SLOT(afterPreflight()));

  // Catch when the filter wants its values updated
  connect(getFilter(), SIGNAL(updateFilterParameters(AbstractFilter*)),
          this, SLOT(filterNeedsInputParameters(AbstractFilter*)));


  connect(xData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );
  connect(yData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );
  connect(zData, SIGNAL(textChanged(const QString&)),
          this, SLOT(widgetChanged(const QString&) ) );

  QLocale loc = QLocale::system();

  QDoubleValidator* xVal = new QDoubleValidator(xData);
  xData->setValidator(xVal);
  xVal->setLocale(loc);

  QDoubleValidator* yVal = new QDoubleValidator(yData);
  yData->setValidator(yVal);
  yVal->setLocale(loc);

  QDoubleValidator* zVal = new QDoubleValidator(zData);
  zData->setValidator(zVal);
  zVal->setLocale(loc);
  if (getFilterParameter() != NULL)
  {
    label->setText(getFilterParameter()->getHumanLabel() );

    FloatVec3_t data = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<FloatVec3_t>();

    xData->setText(loc.toString(data.x));
    yData->setText(loc.toString(data.y));
    zData->setText(loc.toString(data.z));
  }

  errorLabel->hide();

}
Пример #2
0
TrackView::TrackView(SyncPage *page, QWidget *parent) :
    QAbstractScrollArea(parent),
    page(page),
    windowRows(0),
    readOnly(false),
    dragging(false)
{
	Q_ASSERT(page);

	lineEdit = new QLineEdit(this);
	lineEdit->setAutoFillBackground(true);
	lineEdit->hide();
	QDoubleValidator *lineEditValidator = new QDoubleValidator();
	lineEditValidator->setNotation(QDoubleValidator::StandardNotation);
	lineEditValidator->setLocale(QLocale::c());
	lineEdit->setValidator(lineEditValidator);

	QObject::connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));

	viewport()->setAutoFillBackground(false);

	setFocus(Qt::OtherFocusReason);

	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);

	scrollPosX = 0;
	scrollPosY = 0;

	editRow = 0;
	editTrack = 0;

	selectionStart = selectionEnd = QPoint(0, 0);

	updateFont(fontMetrics());
	updatePalette();

	stepPen = QPen();
	lerpPen = QPen(QBrush(Qt::red), 2);
	smoothPen = QPen(QBrush(Qt::green), 2);
	rampPen = QPen(QBrush(Qt::blue), 2);

	editBrush = Qt::yellow;
	bookmarkBrush = QColor(128, 128, 255);

	handCursor = QCursor(Qt::OpenHandCursor);
	setMouseTracking(true);

	setupScrollBars();
	QObject::connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onHScroll(int)));
	QObject::connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(onVScroll(int)));

	QObject::connect(page, SIGNAL(trackHeaderChanged(int)), this, SLOT(onTrackHeaderChanged(int)));
	QObject::connect(page, SIGNAL(trackDataChanged(int, int, int)), this, SLOT(onTrackDataChanged(int, int, int)));
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QWidget* ComparisonSelectionItemDelegate::createEditor(QWidget* widgetParent, const QStyleOptionViewItem& option, const QModelIndex& index) const
{
  QLineEdit* featureValue = NULL;
  QDoubleValidator* featureValueValidator = NULL;
 
  QComboBox* operatorCombo = NULL;

  ComparisonSelectionTableModel* tableModel = qobject_cast<ComparisonSelectionTableModel*>(parent());

  QStringList operators;
  operators << (SIMPL::Comparison::Strings::LessThan)
            << (SIMPL::Comparison::Strings::GreaterThan)
            << (SIMPL::Comparison::Strings::Equal);

  //QComboBox* phaseCombo = NULL;
  QStringList phases;
  for(int i = 0; i < m_NumberOfPhases; ++i)
  {
    phases << QString::number(i + 1);
  }
  bool ok = false;
  qint32 col = index.column();
  switch(col)
  {
    case ComparisonSelectionTableModel::FeatureName:
      operatorCombo = new QComboBox(widgetParent);
      operatorCombo->addItems(m_FeatureList);
      operatorCombo->setAutoFillBackground(true);
      if(tableModel)
      {
        connect(operatorCombo, SIGNAL(currentIndexChanged(int)),
                this, SLOT(arrayNameChangedData(int)));
      }
      return operatorCombo;
    case ComparisonSelectionTableModel::FeatureValue:
    {
      featureValue = new QLineEdit(widgetParent);
      featureValue->setFrame(false);
      featureValueValidator = new QDoubleValidator(featureValue);
      featureValueValidator->setRange(-1.0f * std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), 6);
      featureValueValidator->setLocale(QLocale::system());
      featureValue->setValidator(featureValueValidator);
      QVariant var = index.model()->data(index);
      featureValue->setText(QString::number(var.toDouble(&ok), 'g', 6));
      if (tableModel)
      {
        connect(featureValue, SIGNAL(textChanged(const QString&)),
                this, SLOT(valueChangedData(const QString&)));
      }
      return featureValue;
    }
    case ComparisonSelectionTableModel::FeatureOperator:
      operatorCombo = new QComboBox(widgetParent);
      operatorCombo->addItems(operators);
      operatorCombo->setAutoFillBackground(true);
      if (tableModel)
      {
        connect(operatorCombo, SIGNAL(currentIndexChanged(int)),
                this, SLOT(operatorChangedData(int)));
      }
      return operatorCombo;
    //        case ComparisonSelectionTableModel::FeaturePhaseValue:
    //          phaseCombo = new QComboBox(parent);
    //          phaseCombo->addItems(phases);
    //          phaseCombo->setAutoFillBackground(true);
    //          return phaseCombo;
    default:
      break;
  }
  return QStyledItemDelegate::createEditor(widgetParent, option, index);
}
Пример #4
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PrimaryPhaseWidget::setupGui()
{
  distributionTypeCombo->addItem(DREAM3D::StringConstants::BetaDistribution.toLatin1().data());
  distributionTypeCombo->addItem(DREAM3D::StringConstants::LogNormalDistribution.toLatin1().data());
  distributionTypeCombo->addItem(DREAM3D::StringConstants::PowerLawDistribution.toLatin1().data());
  distributionTypeCombo->setCurrentIndex(DREAM3D::DistributionType::LogNormal);
  // Turn off all the plot widgets
  setTabsPlotTabsEnabled(false);

  QLocale loc = QLocale::system();

  microstructurePresetCombo->blockSignals(true);
  // Register all of our Microstructure Preset Factories
  AbstractMicrostructurePresetFactory::Pointer presetFactory = AbstractMicrostructurePresetFactory::NullPointer();

  //Register the Equiaxed Preset
  presetFactory = RegisterPresetFactory<PrimaryEquiaxedPresetFactory>(microstructurePresetCombo);
  QString presetName = (presetFactory->displayName());
  MicrostructurePresetManager::Pointer manager = MicrostructurePresetManager::instance();
  m_MicroPreset = manager->createNewPreset(presetName);

  // Register the Rolled Preset
  presetFactory = RegisterPresetFactory<PrimaryRolledPresetFactory>(microstructurePresetCombo);

  m_MuValidator = new QDoubleValidator(m_Mu_SizeDistribution);
  m_MuValidator->setLocale(loc);
  m_MuValidator->setRange(0.0001, 10.0, 4);

  m_Mu_SizeDistribution->setValidator(m_MuValidator);


  m_SigmaValidator = new QDoubleValidator(m_Sigma_SizeDistribution);
  m_SigmaValidator->setLocale(loc);
  m_SigmaValidator->setRange(0.0000, 1.0, 4);
  m_Sigma_SizeDistribution->setValidator(m_SigmaValidator);

  QDoubleValidator* minVal = new QDoubleValidator(0.000, std::numeric_limits<double>::infinity(), 4, m_MinSigmaCutOff);
  minVal->setLocale(loc);
  m_MinSigmaCutOff->setValidator(minVal);

  QDoubleValidator* maxVal = new QDoubleValidator(0.000, std::numeric_limits<double>::infinity(), 4, m_MinSigmaCutOff);
  maxVal->setLocale(loc);
  m_MaxSigmaCutOff->setValidator(maxVal);


  // Select the first Preset in the list
  microstructurePresetCombo->setCurrentIndex(0);
  microstructurePresetCombo->blockSignals(false);


  float mu = 1.0f;
  float sigma = 0.1f;
  float minCutOff = 5.0f;
  float maxCutOff = 5.0f;
  float binStepSize = 0.5f;

  StatsGenPlotWidget* w = m_Omega3Plot;

  w->setPlotTitle(QString("Size Vs. Omega 3"));
  w->setXAxisName(QString("Omega 3"));
  w->setYAxisName(QString("Frequency"));
  w->setDistributionType(DREAM3D::DistributionType::Beta);
  w->setStatisticsType(DREAM3D::StatisticsType::Feature_SizeVOmega3);
  w->blockDistributionTypeChanges(true);
  w->setRowOperationEnabled(false);
  w->setMu(mu);
  w->setSigma(sigma);
  w->setMinCutOff(minCutOff);
  w->setMaxCutOff(maxCutOff);
  w->setBinStep(binStepSize);
  connect(m_Omega3Plot, SIGNAL(userEditedData()),
          this, SLOT(dataWasEdited()));


  w = m_BOverAPlot;
  w->setPlotTitle(QString("B/A Shape Distribution"));
  w->setXAxisName(QString("B/A"));
  w->setYAxisName(QString("Frequency"));
  w->setDistributionType(DREAM3D::DistributionType::Beta);
  w->setStatisticsType(DREAM3D::StatisticsType::Feature_SizeVBoverA);
  w->blockDistributionTypeChanges(true);
  w->setRowOperationEnabled(false);
  w->setMu(mu);
  w->setSigma(sigma);
  w->setMinCutOff(minCutOff);
  w->setMaxCutOff(maxCutOff);
  w->setBinStep(binStepSize);
  connect(m_BOverAPlot, SIGNAL(userEditedData()),
          this, SLOT(dataWasEdited()));

  w = m_COverAPlot;
  w->setPlotTitle(QString("C/A Shape Distribution"));
  w->setXAxisName(QString("C/A"));
  w->setYAxisName(QString("Frequency"));
  w->setDistributionType(DREAM3D::DistributionType::Beta);
  w->setStatisticsType(DREAM3D::StatisticsType::Feature_SizeVCoverA);
  w->blockDistributionTypeChanges(true);
  w->setRowOperationEnabled(false);
  w->setMu(mu);
  w->setSigma(sigma);
  w->setMinCutOff(minCutOff);
  w->setMaxCutOff(maxCutOff);
  w->setBinStep(binStepSize);
  connect(m_COverAPlot, SIGNAL(userEditedData()),
          this, SLOT(dataWasEdited()));

  w = m_NeighborPlot;
  w->setPlotTitle(QString("Neighbors Distributions"));
  w->setXAxisName(QString("Number of Features (within 1 diameter)"));
  w->setYAxisName(QString("Frequency"));
  w->setDistributionType(DREAM3D::DistributionType::LogNormal);
  w->setStatisticsType(DREAM3D::StatisticsType::Feature_SizeVNeighbors);
  w->blockDistributionTypeChanges(true);
  w->setRowOperationEnabled(false);
  w->setMu(mu);
  w->setSigma(sigma);
  w->setMinCutOff(minCutOff);
  w->setMaxCutOff(maxCutOff);
  w->setBinStep(binStepSize);
  connect(m_NeighborPlot, SIGNAL(userEditedData()),
          this, SLOT(dataWasEdited()));


  m_SizeDistributionPlot->setCanvasBackground(QColor(Qt::white));
  m_SizeDistributionPlot->setTitle("Size Distribution");

  m_grid = new QwtPlotGrid;
  m_grid->enableXMin(true);
  m_grid->enableYMin(true);
#if (QWT_VERSION > 0x060000)
  m_grid->setMajorPen(QPen(Qt::gray, 0, Qt::SolidLine));
  m_grid->setMinorPen(QPen(Qt::lightGray, 0, Qt::DotLine));
#else
  m_grid->setMajPen(QPen(Qt::gray, 0, Qt::SolidLine));
  m_grid->setMinPen(QPen(Qt::lightGray, 0, Qt::DotLine));
#endif
  m_grid->attach(m_SizeDistributionPlot);

  // For the ODF Tab we want the MDF functionality
  m_ODFWidget->enableMDFTab(true);
  // Remove any Axis Decorations. The plots are explicitly know to have a -1 to 1 axis min/max
  m_ODFWidget->setEnableAxisDecorations(false);

  // Remove any Axis Decorations. The plots are explicitly know to have a -1 to 1 axis min/max
  m_AxisODFWidget->setEnableAxisDecorations(false);

  updateSizeDistributionPlot();
  calculateNumberOfBins();
}