static void PopulateAttributeMatrixComboBox(AbstractFilter* filter, FilterParameter* filterParameter,
                                            QComboBox* dcCombo, QComboBox* amCombo,
                                            DataContainerArrayProxy& dcaProxy)
    {
      FilterParameterType* fp = dynamic_cast<FilterParameterType*>(filterParameter);
      assert(fp != NULL);
      DataContainerArray::Pointer dca = filter->getDataContainerArray();
      if (NULL == dca.get()) { return; }

      QString dcName = dcCombo->currentText();

      // Clear the AttributeMatrix List
      bool alreadyBlocked = false;
      if(amCombo->signalsBlocked()) { alreadyBlocked = true; }
      amCombo->blockSignals(true);
      amCombo->clear();

      // Loop over the data containers until we find the proper data container
      QList<DataContainerProxy> containers = dcaProxy.dataContainers.values();
      QListIterator<DataContainerProxy> containerIter(containers);
      QVector<unsigned int> defVec = fp->getDefaultAttributeMatrixTypes();
      while(containerIter.hasNext())
      {
        DataContainerProxy dc = containerIter.next();

        if(dc.name.compare(dcName) == 0 )
        {
          // We found the proper Data Container, now populate the AttributeMatrix List
          QMap<QString, AttributeMatrixProxy> attrMats = dc.attributeMatricies;
          QMapIterator<QString, AttributeMatrixProxy> attrMatsIter(attrMats);
          while(attrMatsIter.hasNext() )
          {
            attrMatsIter.next();
            QString amName = attrMatsIter.key();
            AttributeMatrix::Pointer am = dca->getAttributeMatrix(DataArrayPath(dc.name, amName, ""));
            amCombo->addItem(amName);

            if (NULL != am.get() && defVec.isEmpty() == false && defVec.contains(am->getType()) == false)
            {
              QStandardItemModel* model = qobject_cast<QStandardItemModel*>(amCombo->model());
              if (NULL != model)
              {
                QStandardItem* item = model->item(amCombo->findText(amName));
                if (NULL != item)
                {
                  item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
                }
              }
            }
          }
        }
      }

      if(!alreadyBlocked) { // Only unblock if this function blocked the signals.
        amCombo->blockSignals(false);
      }
    }
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void PhaseTypeSelectionWidget::populateComboBoxes()
{
  //  std::cout << "void PhaseTypeSelectionWidget::populateComboBoxesWithSelection()" << std::endl;


  // Now get the DataContainerArray from the Filter instance
  // We are going to use this to get all the current DataContainers
  DataContainerArray::Pointer dca = getFilter()->getDataContainerArray();
  if(NULL == dca.get()) { return; }

  // Grab what is currently selected
  QString curDcName = dataContainerCombo->currentText();
  QString curAmName = attributeMatrixCombo->currentText();

  // Check to see if we have any DataContainers to actually populate drop downs with.
  if(dca->getDataContainers().size() == 0)
  {
    dataContainerCombo->clear();
    attributeMatrixCombo->clear();
    return;
  }
  // Cache the DataContainerArray Structure for our use during all the selections
  m_DcaProxy = DataContainerArrayProxy(dca.get());

  // Populate the DataContainerArray Combo Box with all the DataContainers
  QList<DataContainerProxy> dcList = m_DcaProxy.dataContainers.values();
  QListIterator<DataContainerProxy> iter(dcList);
  dataContainerCombo->clear();
  while(iter.hasNext() )
  {
    DataContainerProxy dc = iter.next();
    dataContainerCombo->addItem(dc.name);
  }

  // Get what is in the filter
  PhaseTypeSelectionFilterParameter* p = dynamic_cast<PhaseTypeSelectionFilterParameter*>(getFilterParameter());
  QVariant qvSelectedPath = getFilter()->property(p->getAttributeMatrixPathProperty().toLatin1().constData());
  DataArrayPath selectedPath = qvSelectedPath.value<DataArrayPath>();

  QString filtDcName = selectedPath.getDataContainerName();
  QString filtAmName = selectedPath.getAttributeMatrixName();

  QString dcName;
  QString amName;

  // If EVERYTHING is empty, then try the default value
  if(filtDcName.isEmpty() && filtAmName.isEmpty()
      && curDcName.isEmpty() && curAmName.isEmpty() )
  {
    DataArrayPath daPath = getFilterParameter()->getDefaultValue().value<DataArrayPath>();
    dcName = daPath.getDataContainerName();
    amName = daPath.getAttributeMatrixName();
  }
  else
  {
    // Now to figure out which one of these to use. If this is the first time through then what we picked up from the
    // gui will be empty strings because nothing is there. If there is something in the filter then we should use that.
    // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight
    // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future
    // versions that something else is driving DREAM3D and pushing the changes to the filter and we need to reflect those
    // changes in the GUI, like a testing script?

    dcName = checkStringValues(curDcName, filtDcName);
    if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; }
    amName = checkStringValues(curAmName, filtAmName);
    if( !dca->doesAttributeMatrixExist(DataArrayPath(dcName, amName, "") ) ) { amName = ""; }
  }

  bool didBlock = false;

  if (!dataContainerCombo->signalsBlocked()) { didBlock = true; }
  dataContainerCombo->blockSignals(true);
  int dcIndex = dataContainerCombo->findText(dcName);

  dataContainerCombo->setCurrentIndex(dcIndex);
  populateAttributeMatrixList();

  if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; }

  if(!attributeMatrixCombo->signalsBlocked()) { didBlock = true; }
  attributeMatrixCombo->blockSignals(true);

  if (dcIndex < 0)
  {
    attributeMatrixCombo->setCurrentIndex(-1);
  }
  else
  {
    int amIndex = attributeMatrixCombo->findText(amName);
    attributeMatrixCombo->setCurrentIndex(amIndex);
  }

  if(didBlock) { attributeMatrixCombo->blockSignals(false); didBlock = false; }

}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DataArraySelectionWidget::populateComboBoxes()
{
  //qDebug() << "-----------------------------------------------";
  //qDebug() << getFilter()->getHumanLabel() << "  " << getFilterParameter()->getHumanLabel() << " DataArraySelectionWidget::populateComboBoxes()";
  // Now get the DataContainerArray from the Filter instance
  // We are going to use this to get all the current DataContainers
  DataContainerArray::Pointer dca = getFilter()->getDataContainerArray();
  if(NULL == dca.get()) { return; }

  //qDebug() << getFilter()->getHumanLabel() << "  " << getFilterParameter()->getHumanLabel();
  // Grab what is currently selected
  QString curDcName = dataContainerCombo->currentText();
  QString curAmName = attributeMatrixCombo->currentText();
  QString curDaName = attributeArrayCombo->currentText();
  //qDebug() << "Current ComboBox Value: " << curDcName << "::" << curAmName << "::" << curDaName;

  // Check to see if we have any DataContainers to actually populate drop downs with.
  if(dca->getDataContainers().size() == 0)
  {
    dataContainerCombo->clear();
    attributeMatrixCombo->clear();
    attributeArrayCombo->clear();
    return;
  }
  // Cache the DataContainerArray Structure for our use during all the selections
  m_DcaProxy = DataContainerArrayProxy(dca.get());

  // Populate the DataContainerArray Combo Box with all the DataContainers
  QList<DataContainerProxy> dcList = m_DcaProxy.dataContainers.values();
  QListIterator<DataContainerProxy> iter(dcList);
  dataContainerCombo->clear();
  while(iter.hasNext() )
  {
    DataContainerProxy dc = iter.next();
    dataContainerCombo->addItem(dc.name);
//    if(dataContainerCombo->findText(dc.name) == -1 )
//    {
//      int index = dataContainerCombo->currentIndex();
//      dataContainerCombo->addItem(dc.name);
//      dataContainerCombo->setCurrentIndex(index);
//    }
  }

  // Get what is in the filter
  DataArrayPath selectedPath = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<DataArrayPath>();

  // Split the path up to make sure we have a valid path separated by the "|" character
  QString filtDcName = selectedPath.getDataContainerName();
  QString filtAmName = selectedPath.getAttributeMatrixName();
  QString filtDaName = selectedPath.getDataArrayName();

  QString dcName;
  QString amName;
  QString daName;

  // If EVERYTHING is empty, then try the default value
  if(filtDcName.isEmpty() && filtAmName.isEmpty() && filtDaName.isEmpty()
      && curDcName.isEmpty() && curAmName.isEmpty() && curDaName.isEmpty() )
  {
    DataArrayPath daPath = getFilterParameter()->getDefaultValue().value<DataArrayPath>();
    dcName = daPath.getDataContainerName();
    amName = daPath.getAttributeMatrixName();
    daName = daPath.getDataArrayName();
  }
  else
  {
    // Now to figure out which one of these to use. If this is the first time through then what we picked up from the
    // gui will be empty strings because nothing is there. If there is something in the filter then we should use that.
    // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight
    // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future
    // versions that something else is driving DREAM3D and pushing the changes to the filter and we need to reflect those
    // changes in the GUI, like a testing script?

    dcName = checkStringValues(curDcName, filtDcName);
    if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; }
    amName = checkStringValues(curAmName, filtAmName);
    if ( !dca->doesAttributeMatrixExist(DataArrayPath(dcName, amName, "") ) ) { amName = ""; }
    daName = checkStringValues(curDaName, filtDaName);
    if ( !dca->doesAttributeArrayExist(DataArrayPath(dcName, amName, daName) )) { daName = ""; }
  }

  bool didBlock = false;

  if (!dataContainerCombo->signalsBlocked()) { didBlock = true; }
  dataContainerCombo->blockSignals(true);
  int dcIndex = dataContainerCombo->findText(dcName);
  dataContainerCombo->setCurrentIndex(dcIndex);
  populateAttributeMatrixList();

  if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; }
  if(!attributeMatrixCombo->signalsBlocked()) { didBlock = true; }
  attributeMatrixCombo->blockSignals(true);

  int amIndex = -1;
  if (dcIndex < 0)
  {
    attributeMatrixCombo->setCurrentIndex(-1);
    attributeArrayCombo->setCurrentIndex(-1);
  }
  else
  {
    amIndex = attributeMatrixCombo->findText(amName);
    attributeMatrixCombo->setCurrentIndex(amIndex);
    populateAttributeArrayList();
  }

  if(didBlock) { attributeMatrixCombo->blockSignals(false); didBlock = false; }
  if(!attributeArrayCombo->signalsBlocked()) { didBlock = true; }
  attributeArrayCombo->blockSignals(true);

  if (amIndex < 0)
  {
    attributeArrayCombo->setCurrentIndex(-1);
  }
  else
  {
    int daIndex = attributeArrayCombo->findText(daName);

    // The DataArray Name was empty, lets instantiate the filter and get the default value and try that
    if (daIndex < 0)
    {
      QVariant var = getFilterParameter()->getDefaultValue();
      DataArrayPath path = var.value<DataArrayPath>();
      daName = path.getDataArrayName(); // Pick up the DataArray Name from a Default instantiation of the filter
      daIndex = attributeArrayCombo->findText(daName);
    }

    attributeArrayCombo->setCurrentIndex(daIndex); // we set the selection but we are NOT triggering anything so we should
  }

  if(didBlock) { attributeArrayCombo->blockSignals(false); didBlock = false; }// not be triggering an infinte recursion of preflights

}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DataArrayCreationWidget::populateComboBoxes()
{
  //  std::cout << "void DataArrayCreationWidget::populateComboBoxesWithSelection()" << std::endl;


  // Now get the DataContainerArray from the Filter instance
  // We are going to use this to get all the current DataContainers
  DataContainerArray::Pointer dca = getFilter()->getDataContainerArray();
  if(NULL == dca.get()) { return; }

  // Check to see if we have any DataContainers to actually populate drop downs with.
  if(dca->getDataContainers().size() == 0)
  {
    return;
  }
  // Cache the DataContainerArray Structure for our use during all the selections
  m_DcaProxy = DataContainerArrayProxy(dca.get());

  // Populate the DataContainer ComboBox
  FilterPararameterWidgetUtils::PopulateDataContainerComboBox<DataArrayCreationFilterParameter>(getFilter(), getFilterParameter(), dataContainerCombo, m_DcaProxy);

  // Grab what is currently selected
  QString curDcName = dataContainerCombo->currentText();
  QString curAmName = attributeMatrixCombo->currentText();
  QString curDaName = dataArrayName->text();

  // Get what is in the filter
  DataArrayPath selectedPath = getFilter()->property(PROPERTY_NAME_AS_CHAR).value<DataArrayPath>();

  // Split the path up to make sure we have a valid path separated by the "|" character

  QString filtDcName = selectedPath.getDataContainerName();
  QString filtAmName = selectedPath.getAttributeMatrixName();
  QString filtDaName = selectedPath.getDataArrayName();

  // Now to figure out which one of these to use. If this is the first time through then what we picked up from the
  // gui will be empty strings because nothing is there. If there is something in the filter then we should use that.
  // If there is something in both of them and they are NOT equal then we have a problem. Use the flag m_DidCausePreflight
  // to determine if the change from the GUI should over ride the filter or vice versa. there is a potential that in future
  // versions that something else is driving SIMPLView and pushing the changes to the filter and we need to reflect those
  // changes in the GUI, like a testing script?

  QString dcName = checkStringValues(curDcName, filtDcName);
  if( !dca->doesDataContainerExist(dcName) ) { dcName = ""; }
  QString amName = checkStringValues(curAmName, filtAmName);
  if ( !dca->doesAttributeMatrixExist(DataArrayPath(dcName, amName, "") ) ) { amName = ""; }
  QString daName = checkStringValues(curDaName, filtDaName);
  //if ( !dca->doesAttributeArrayExist(DataArrayPath(dcName, amName, daName) )) { daName = ""; }

  bool didBlock = false;

  if (!dataContainerCombo->signalsBlocked()) { didBlock = true; }
  dataContainerCombo->blockSignals(true);

  int dcIndex = dataContainerCombo->findText(dcName);
  dataContainerCombo->setCurrentIndex(dcIndex);
  FilterPararameterWidgetUtils::PopulateAttributeMatrixComboBox<DataArrayCreationFilterParameter>(getFilter(), getFilterParameter(), dataContainerCombo, attributeMatrixCombo, m_DcaProxy);

  if(didBlock) { dataContainerCombo->blockSignals(false); didBlock = false; }

  if(!attributeMatrixCombo->signalsBlocked()) { didBlock = true; }
  attributeMatrixCombo->blockSignals(true);

  if (dcIndex < 0)
  {
    attributeMatrixCombo->setCurrentIndex(-1);
  }
  else
  {
    int amIndex = attributeMatrixCombo->findText(amName);
    attributeMatrixCombo->setCurrentIndex(amIndex);
  }

  if(didBlock) { attributeMatrixCombo->blockSignals(false); didBlock = false; }


  if(!dataArrayName->signalsBlocked()) { didBlock = true; }
  dataArrayName->blockSignals(true);

  dataArrayName->setText(daName);

  if(didBlock) { dataArrayName->blockSignals(false); didBlock = false; }

}
    static void PopulateAttributeArrayList(AbstractFilter* filter, FilterParameter* filterParameter,
                                           QComboBox* dcCombo, QComboBox* amCombo, WidgetType* attributeArraysWidget,
                                           DataContainerArrayProxy& dcaProxy,
                                           QVector<DataArrayPath> selectedPaths)
    {
      FilterParameterType* fp = dynamic_cast<FilterParameterType*>(filterParameter);
      assert(fp != NULL);

      DataContainerArray::Pointer dca = filter->getDataContainerArray();
      if (NULL == dca.get()) { return; }

      attributeArraysWidget->blockSignals(true);
      attributeArraysWidget->clear();

      // Get the selected Data Container Name from the DataContainerList Widget
      QString currentDCName = dcCombo->currentText();
      QString currentAttrMatName = amCombo->currentText();

      // Loop over the data containers until we find the proper data container
      QList<DataContainerProxy> containers = dcaProxy.dataContainers.values();
      QListIterator<DataContainerProxy> containerIter(containers);
      QVector<QString> daTypes = fp->getDefaultAttributeArrayTypes();
      QVector< QVector<size_t> > cDims = fp->getDefaultComponentDimensions();
      while (containerIter.hasNext())
      {
        DataContainerProxy dc = containerIter.next();
        if (dc.name.compare(currentDCName) == 0)
        {
          // We found the proper Data Container, now populate the AttributeMatrix List
          QMap<QString, AttributeMatrixProxy> attrMats = dc.attributeMatricies;
          QMapIterator<QString, AttributeMatrixProxy> attrMatsIter(attrMats);
          while (attrMatsIter.hasNext())
          {
            attrMatsIter.next();
            QString amName = attrMatsIter.key();
            if (amName.compare(currentAttrMatName) == 0)
            {
              // Clear the list of arrays from the QListWidget
              attributeArraysWidget->clear();
              // We found the selected AttributeMatrix, so loop over this attribute matrix arrays and populate the list widget
              AttributeMatrixProxy amProxy = attrMatsIter.value();
              QMap<QString, DataArrayProxy> dataArrays = amProxy.dataArrays;
              QMapIterator<QString, DataArrayProxy> dataArraysIter(dataArrays);
              while (dataArraysIter.hasNext())
              {
                dataArraysIter.next();
                QString daName = dataArraysIter.key();
                QListWidgetItem* daItem = new QListWidgetItem(daName);
                daItem->setCheckState(Qt::Unchecked);

                for (int i = 0; i < selectedPaths.size(); i++)
                {
                  if (selectedPaths.at(i).getDataArrayName() == daName)
                  {
                    daItem->setCheckState(Qt::Checked);
                  }
                }

                IDataArray::Pointer da = dca->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(NULL, DataArrayPath(dc.name, amProxy.name, daName));
                attributeArraysWidget->addItem(daItem);

                if (NULL != da.get() && ((daTypes.isEmpty() == false && daTypes.contains(da->getTypeAsString()) == false) || (cDims.isEmpty() == false && cDims.contains(da->getComponentDimensions()) == false)))
                {
                  QList<QListWidgetItem*> rejectList = attributeArraysWidget->findItems(daName, Qt::MatchRecursive);
                  for (int i = 0; i < rejectList.size(); i++)
                  {
                    QListWidgetItem* item = rejectList[i];
                    item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
                  }
                }
              }
            }
          }
        }
      }

      attributeArraysWidget->blockSignals(false);
    }
    static void PopulateAttributeArrayComboBox(AbstractFilter* filter, FilterParameter* filterParameter,
                                      QComboBox* dcCombo, QComboBox* amCombo, QComboBox* aaCombo,
                                      DataContainerArrayProxy& dcaProxy)
    {
      FilterParameterType* fp = dynamic_cast<FilterParameterType*>(filterParameter);
      assert(fp != NULL);

      DataContainerArray::Pointer dca = filter->getDataContainerArray();
      if (NULL == dca.get()) { return; }
      bool alreadyBlocked = false;
      if(aaCombo->signalsBlocked()) { alreadyBlocked = true; }
      aaCombo->blockSignals(true);
      aaCombo->clear();

      // Get the selected Data Container Name from the DataContainerList Widget
      QString currentDCName = dcCombo->currentText();
      QString currentAttrMatName = amCombo->currentText();

      // Loop over the data containers until we find the proper data container
      QList<DataContainerProxy> containers = dcaProxy.dataContainers.values();
      QListIterator<DataContainerProxy> containerIter(containers);
      QVector<QString> daTypes = fp->getDefaultAttributeArrayTypes();
      QVector< QVector<size_t> > cDims = fp->getDefaultComponentDimensions();
      while (containerIter.hasNext())
      {
        DataContainerProxy dc = containerIter.next();
        if (dc.name.compare(currentDCName) == 0)
        {
          // We found the proper Data Container, now populate the AttributeMatrix List
          QMap<QString, AttributeMatrixProxy> attrMats = dc.attributeMatricies;
          QMapIterator<QString, AttributeMatrixProxy> attrMatsIter(attrMats);
          while (attrMatsIter.hasNext())
          {
            attrMatsIter.next();
            QString amName = attrMatsIter.key();
            if (amName.compare(currentAttrMatName) == 0)
            {
              // Clear the list of arrays from the QListWidget
              aaCombo->clear();
              // We found the selected AttributeMatrix, so loop over this attribute matrix arrays and populate the list widget
              AttributeMatrixProxy amProxy = attrMatsIter.value();
              QMap<QString, DataArrayProxy> dataArrays = amProxy.dataArrays;
              QMapIterator<QString, DataArrayProxy> dataArraysIter(dataArrays);
              while (dataArraysIter.hasNext())
              {
                dataArraysIter.next();
                //DataArrayProxy daProxy = dataArraysIter.value();
                QString daName = dataArraysIter.key();
                IDataArray::Pointer da = dca->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(NULL, DataArrayPath(dc.name, amProxy.name, daName));
                aaCombo->addItem(daName);

                if (NULL != da.get() && ((daTypes.isEmpty() == false && daTypes.contains(da->getTypeAsString()) == false) || (cDims.isEmpty() == false && cDims.contains(da->getComponentDimensions()) == false)))
                {
                  QStandardItemModel* model = qobject_cast<QStandardItemModel*>(aaCombo->model());
                  if (NULL != model)
                  {
                    QStandardItem* item = model->item(aaCombo->findText(daName));
                    if (NULL != item)
                    {
                      item->setFlags(item->flags() & ~Qt::ItemIsEnabled);
                    }
                  }
                }
              }
            }
          }
        }

        aaCombo->setCurrentIndex(-1);
        if(alreadyBlocked == false)
        {
          aaCombo->blockSignals(false);
        }
      }
    }