Skip to content

Commit

Permalink
Fix bad logic for certain Data Structure requirements for Filter Para…
Browse files Browse the repository at this point in the history
…meters

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
imikejackson committed Feb 19, 2021
1 parent 1d8ba0b commit 4998629
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 70 deletions.
7 changes: 0 additions & 7 deletions Source/SIMPLib/Common/SIMPLibSetGetMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,6 @@ public:
return m_##prpty; \
}

// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
#define SIMPL_CONTAINER_TYPE(thisClass, container) \
typedef(container)<thisClass> ContainerT; \
typedef std::shared_ptr<(container) < (thisClass)>> ContainerPType;

/**
* @brief Creates a "setter" method to set the property.
*/
Expand Down
153 changes: 94 additions & 59 deletions Source/SVWidgetsLib/Widgets/DataArrayPathSelectionWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,6 @@
#include "SVWidgetsLib/QtSupport/QtSSettings.h"
#include "SVWidgetsLib/Widgets/SVStyle.h"

namespace
{

/**
* @brief CheckPathRequirements This is a common function that 3 other methods below implement
* @param filter AbstractFilter
* @param path The DataArrayPath
* @param reqs The requirements
* @return Boolean if we pass or not.
*/
template <typename RequirementsType>
bool CheckDataPathAndRequirements(AbstractFilter* filter, const DataArrayPath& path, const RequirementsType& reqs)
{
if(nullptr == filter)
{
return false;
}
if(nullptr == filter->getDataContainerArray())
{
return false;
}

// Check that the DataContainer exists
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
if(nullptr == dc)
{
return false;
}

// Check Geometry
if(!reqs.dcGeometryTypes.empty())
{
// Unknown Geometry gets a pass
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
{
IGeometry::Pointer geom = dc->getGeometry();
if(nullptr == geom)
{
return false;
}
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
{
return false;
}
}
}

return true;
}

} // namespace
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -231,7 +180,41 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
{
return false;
}
return ::CheckDataPathAndRequirements(filter, path, reqs);
if(nullptr == filter)
{
return false;
}
if(nullptr == filter->getDataContainerArray())
{
return false;
}

// Check that the DataContainer exists
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
if(nullptr == dc)
{
return false;
}

// Check Geometry
if(!reqs.dcGeometryTypes.empty())
{
// Unknown Geometry gets a pass
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
{
IGeometry::Pointer geom = dc->getGeometry();
if(nullptr == geom)
{
return false;
}
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
{
return false;
}
}
}

return true;
}

// -----------------------------------------------------------------------------
Expand All @@ -243,13 +226,39 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
{
return false;
}

if(!::CheckDataPathAndRequirements(filter, path, reqs))
if(nullptr == filter)
{
return false;
}
if(nullptr == filter->getDataContainerArray())
{
return false;
}
// This is OK because one of the checks in the function above is if "dc" would be nullptr

// Check that the DataContainer exists
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
if(nullptr == dc)
{
return false;
}

// Check if geometry exists and matches the requirements only if a geometry is required
if(!reqs.dcGeometryTypes.empty())
{
// Unknown Geometry gets a pass
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
{
IGeometry::Pointer geom = dc->getGeometry();
if(nullptr == geom)
{
return false;
}
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
{
return false;
}
}
}

// Check AttributeMatrix
AttributeMatrix::Pointer am = dc->getAttributeMatrix(path);
Expand Down Expand Up @@ -278,13 +287,39 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,
{
return false;
}

if(!::CheckDataPathAndRequirements(filter, path, reqs))
if(nullptr == filter)
{
return false;
}
if(nullptr == filter->getDataContainerArray())
{
return false;
}
// This is OK because one of the checks in the function above is if "dc" would be nullptr

// Check that the DataContainer exists
DataContainer::Pointer dc = filter->getDataContainerArray()->getDataContainer(path);
if(nullptr == dc)
{
return false;
}

// Check if geometry exists and matches the requirements only if a geometry is required
if(!reqs.dcGeometryTypes.empty())
{
// Unknown Geometry gets a pass
if(!SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Unknown))
{
IGeometry::Pointer geom = dc->getGeometry();
if(nullptr == geom)
{
return false;
}
if(!SIMPL::contains(reqs.dcGeometryTypes, geom->getGeometryType()) && !SIMPL::contains(reqs.dcGeometryTypes, IGeometry::Type::Any))
{
return false;
}
}
}

// Check AttributeMatrix
AttributeMatrix::Pointer am = dc->getAttributeMatrix(path);
Expand All @@ -295,7 +330,7 @@ bool DataArrayPathSelectionWidget::CheckPathRequirements(AbstractFilter* filter,

if(!SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Unknown))
{
if(!reqs.amTypes.empty() && !(SIMPL::contains(reqs.amTypes, am->getType()) && SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Any)))
if(!reqs.amTypes.empty() && !(SIMPL::contains(reqs.amTypes, am->getType()) || SIMPL::contains(reqs.amTypes, AttributeMatrix::Type::Any)))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,10 +453,10 @@ void DataFormatPage::createAMSelectionMenu()
// Get the DataContainerArray object
// Loop over the data containers until we find the proper data container
DataContainerArray::Container containers = dca->getDataContainers();
std::vector<QString> daTypes; // = m_FilterParameter->getDefaultAttributeArrayTypes();
QVector<std::vector<size_t>> cDims; // = m_FilterParameter->getDefaultComponentDimensions();
AttributeMatrix::Types amTypes; // = m_FilterParameter->getDefaultAttributeMatrixTypes();
IGeometry::Types geomTypes; // = m_FilterParameter->getDefaultGeometryTypes();
std::vector<QString> daTypes; // = m_FilterParameter->getDefaultAttributeArrayTypes();
QVector<std::vector<size_t>> cDims; // = m_FilterParameter->getDefaultComponentDimensions();
AttributeMatrix::Types amTypes; // = m_FilterParameter->getDefaultAttributeMatrixTypes();
IGeometry::Types geomTypes; // = m_FilterParameter->getDefaultGeometryTypes();

for(DataContainer::Pointer dc : containers)
{
Expand Down

0 comments on commit 4998629

Please sign in to comment.