Esempio n. 1
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MoveData::dataCheck()
{
  setErrorCondition(0);
  DataArrayPath amSrcPath = getAttributeMatrixSource();
  DataArrayPath amDestPath = getAttributeMatrixDestination();
  DataArrayPath daSrcPath = getDataArraySource();

  if (getWhatToMove() == k_MoveAttributeMatrix)
  {
    DataContainer::Pointer amDestDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, getDataContainerDestination());
    DataContainer::Pointer amSrcDataContainer = getDataContainerArray()->getPrereqDataContainer<AbstractFilter>(this, amSrcPath.getDataContainerName());
    AttributeMatrix::Pointer amSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amSrcPath, -301);

    if(getErrorCondition() < 0) { return; }

    if (amSrcDataContainer->getName() == amDestDataContainer->getName())
    {
      QString ss = QObject::tr("The source and destination Data Container are the same.  Is this what you meant to do?");
      notifyWarningMessage(getHumanLabel(), ss, getErrorCondition());
      return;
    }

    amDestDataContainer->addAttributeMatrix(amSrcAttributeMatrix->getName(), amSrcAttributeMatrix);
    amSrcDataContainer->removeAttributeMatrix(amSrcAttributeMatrix->getName());
  }
  else if (getWhatToMove() == k_MoveDataArray )
  {
    AttributeMatrix::Pointer daSrcAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, daSrcPath, -301);
    AttributeMatrix::Pointer daDestAttributeMatrix = getDataContainerArray()->getPrereqAttributeMatrixFromPath<AbstractFilter>(this, amDestPath, -301);
    IDataArray::Pointer daSrcDataArray = getDataContainerArray()->getPrereqIDataArrayFromPath<IDataArray, AbstractFilter>(this, daSrcPath);

    if(getErrorCondition() < 0) { return; }

    if (daDestAttributeMatrix->getNumTuples() != daSrcDataArray->getNumberOfTuples())
    {
      setErrorCondition(-11019);
      QString ss = QObject::tr("The number of tuples of source Attribute Array (%1) and destination Attribute Matrix (%2) do not match").arg(daSrcDataArray->getNumberOfTuples()).arg(daDestAttributeMatrix->getNumTuples());
      notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
      return;
    }
    else if (amSrcPath == amDestPath)
    {
      QString ss = QObject::tr("The source and destination Attribute Matrix are the same.  Is this what you meant to do?");
      notifyWarningMessage(getHumanLabel(), ss, getErrorCondition());
      return;
    }

    daDestAttributeMatrix->addAttributeArray(daSrcPath.getDataArrayName(), daSrcDataArray);
    daSrcAttributeMatrix->removeAttributeArray(daSrcPath.getDataArrayName());
  }
  else
  {
    setErrorCondition(-11020);
    QString ss = QObject::tr("Neither an Attribute Matrix nor an Attribute Array was selected to be moved");
    notifyErrorMessage(getHumanLabel(), ss, getErrorCondition());
    return;
  }
}
Esempio n. 2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MoveData::readFilterParameters(AbstractFilterParametersReader* reader, int index)
{
    reader->openFilterGroup(this, index);
    setWhatToMove( reader->readValue("WhatToMove", getWhatToMove() ) );
    setDataContainerDestination( reader->readString("DataContainerDestination", getDataContainerDestination() ) );
    setAttributeMatrixSource( reader->readDataArrayPath("AttributeMatrixSource", getAttributeMatrixSource() ) );
    setAttributeMatrixDestination( reader->readDataArrayPath("AttributeMatrixDestination", getAttributeMatrixDestination() ) );
    setDataArraySource( reader->readDataArrayPath("DataArraySource", getDataArraySource() ) );
    reader->closeFilterGroup();
}
Esempio n. 3
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void MoveData::setupFilterParameters()
{
    FilterParameterVector parameters;

    QStringList linkedProps;
    linkedProps << "DataContainerDestination" << "AttributeMatrixSource" << "AttributeMatrixDestination" << "DataArraySource";
    {
        LinkedChoicesFilterParameter::Pointer parameter = LinkedChoicesFilterParameter::New();
        parameter->setHumanLabel("Object to Move");
        parameter->setPropertyName("WhatToMove");

        parameter->setDefaultValue(getWhatToMove()); // Just set the first index
        QVector<QString> choices;
        choices.push_back("Attribute Matrix");
        choices.push_back("Attribute Array");
        parameter->setChoices(choices);
        parameter->setLinkedProperties(linkedProps);
        parameter->setEditable(false);
        parameter->setCategory(FilterParameter::Parameter);
        parameters.push_back(parameter);
    }


    parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Attribute Matrix Source", "AttributeMatrixSource", getAttributeMatrixSource(), FilterParameter::RequiredArray, 0));
    parameters.push_back(DataContainerSelectionFilterParameter::New("Data Container Destination", "DataContainerDestination", getDataContainerDestination(), FilterParameter::RequiredArray, 0));
    parameters.push_back(DataArraySelectionFilterParameter::New("Attribute Array Source", "DataArraySource", getDataArraySource(), FilterParameter::RequiredArray, 1));
    parameters.push_back(AttributeMatrixSelectionFilterParameter::New("Attribute Matrix Destination", "AttributeMatrixDestination", getAttributeMatrixDestination(), FilterParameter::RequiredArray, 1));

    setFilterParameters(parameters);
}