Skip to content

Commit

Permalink
Update ComplexFilterGen tool
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
imikejackson committed Mar 1, 2024
1 parent 7ae637f commit ec4aa27
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 33 deletions.
28 changes: 14 additions & 14 deletions Tools/ComplexFilterGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,7 +1240,7 @@ void GenerateHeaderFile(AbstractFilter* filter, const QString& outputDir, const
ptonew << "/* " << filterName << " */\n";

sourceTemplate = sourceTemplate.replace(k_NewIncludeToken, "#include \"" + pluginName + "/Filters/" + filterName + "Filter.hpp\"\n" + k_NewIncludeToken);
sourceTemplate = sourceTemplate.replace(k_SIMPLToComplexToken, "{complex::Uuid::FromString(\"" + prevUuid + "\").value(), complex::FilterTraits<" + filterName + "Filter>::uuid}, // " + filterName +
sourceTemplate = sourceTemplate.replace(k_SIMPLToComplexToken, "{nx::core::Uuid::FromString(\"" + prevUuid + "\").value(), {nx::core::FilterTraits<" + filterName + "Filter>::uuid, &" + filterName + "Filter::FromSIMPLJson}}, // " + filterName +
"\n " + k_SIMPLToComplexToken);

headerTemplate = headerTemplate.replace(k_FILTER_NAME, filterName + "Filter");
Expand Down Expand Up @@ -1347,7 +1347,7 @@ void GenerateAlgorithmFile(AbstractFilter* filter, const QString& outputDir, con
else if(origParamClassName == "LinkedBooleanFilterParameter")
{
// parameterOut << " args.insertOrAssign(" << filterName << "::k_" << propName << "_Key, std::make_any<" << paramType << ">(" << unitTestDefaultValue << "));\n";
// includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
// includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}
else if(origParamClassName == "LinkedChoicesFilterParameter")
{
Expand All @@ -1362,7 +1362,7 @@ void GenerateAlgorithmFile(AbstractFilter* filter, const QString& outputDir, con
parameterOut << "/*[x]*/";
}
// parameterOut << " args.insertOrAssign(" << filterName << "::k_" << propName << "_Key, std::make_any<" << paramType << ">(" << unitTestDefaultValue << "));\n";
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}

if(propInclude == "FileSystemPathParameter")
Expand Down Expand Up @@ -1504,7 +1504,7 @@ void GenerateSourceFile(AbstractFilter* filter, const QString& outputDir, const
linkedOut << " params.linkParameters(k_" << propName << "_Key, k_" << linkedProp << "_Key, true);\n";
}
}
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}
else if(origParamClassName == "LinkedChoicesFilterParameter")
{
Expand Down Expand Up @@ -1533,7 +1533,7 @@ void GenerateSourceFile(AbstractFilter* filter, const QString& outputDir, const
linkedOut << "//TODO: THIS NEEDS TO BE FIXED\n";
}
}
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}
else if(origParamClassName == "PreflightUpdatedValueFilterParameter")
{
Expand All @@ -1550,30 +1550,30 @@ void GenerateSourceFile(AbstractFilter* filter, const QString& outputDir, const
parameterOut << "/*[x]*/";
}
parameterOut << " params.insert(std::make_unique<" << propClass << ">(k_" << propName << "_Key, \"" << propHuman << "\", \"\", " << defaultValue << "));\n";
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}

if(origParamClassName == "DataArrayCreationFilterParameter")
{
actionsOut << " // This block is commented out because it needs some variables to be filled in.\n";
actionsOut << " {\n // auto createArrayAction = std::make_unique<CreateArrayAction>(complex::NumericType::FILL_ME_IN, std::vector<usize>{NUM_TUPLES_VALUE}, NUM_COMPONENTS, p" << propName
<< (endsWithValue ? "" : "Value") << ");\n";
actionsOut << " // resultOutputActions.value().actions.push_back(std::move(createArrayAction));\n }\n";
includeSet.insert("#include \"complex/Filter/Actions/CreateArrayAction.hpp\"\n");
actionsOut << " // resultOutputActions.value().appendAction(std::move(createArrayAction));\n }\n";
includeSet.insert("#include \"simplnx/Filter/Actions/CreateArrayAction.hpp\"\n");
dataArrayCreation++;
}
else if(origParamClassName == "AttributeMatrixCreationFilterParameter")
{
actionsOut << " {\n auto createDataGroupAction = std::make_unique<CreateDataGroupAction>(p" << propName << (endsWithValue ? "" : "Value") << ");\n";
actionsOut << " resultOutputActions.value().actions.push_back(std::move(createDataGroupAction));\n }\n";
includeSet.insert("#include \"complex/Filter/Actions/CreateDataGroupAction.hpp\"\n");
actionsOut << " resultOutputActions.value().appendAction(std::move(createDataGroupAction));\n }\n";
includeSet.insert("#include \"simplnx/Filter/Actions/CreateDataGroupAction.hpp\"\n");
dataArrayCreation++;
}
else if(origParamClassName == "DataContainerCreationFilterParameter")
{
actionsOut << " {\n auto createDataGroupAction = std::make_unique<CreateDataGroupAction>(p" << propName << (endsWithValue ? "" : "Value") << ");\n";
actionsOut << " resultOutputActions.value().actions.push_back(std::move(createDataGroupAction));\n }\n";
includeSet.insert("#include \"complex/Filter/Actions/CreateDataGroupAction.hpp\"\n");
actionsOut << " resultOutputActions.value().appendAction(std::move(createDataGroupAction));\n }\n";
includeSet.insert("#include \"simplnx/Filter/Actions/CreateDataGroupAction.hpp\"\n");
dataArrayCreation++;
}

Expand Down Expand Up @@ -1725,7 +1725,7 @@ void GenerateUnitTestSourceFile(const AbstractFilter::Pointer& filter, const QSt
else if(origParamClassName == "LinkedBooleanFilterParameter")
{
parameterOut << " args.insertOrAssign(" << filterName << "Filter::k_" << propName << "_Key, std::make_any<" << paramType << ">(" << unitTestDefaultValue << "));\n";
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}
else if(origParamClassName == "LinkedChoicesFilterParameter")
{
Expand All @@ -1740,7 +1740,7 @@ void GenerateUnitTestSourceFile(const AbstractFilter::Pointer& filter, const QSt
parameterOut << "/*[x]*/";
}
parameterOut << " args.insertOrAssign(" << filterName << "Filter::k_" << propName << "_Key, std::make_any<" << paramType << ">(" << unitTestDefaultValue << "));\n";
includeOut << "#include \"complex/Parameters/" << propInclude << ".hpp\"\n";
includeOut << "#include \"simplnx/Parameters/" << propInclude << ".hpp\"\n";
}

if(propInclude == "FileSystemPathParameter")
Expand Down
8 changes: 4 additions & 4 deletions Tools/complex_algorithm.cpp.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include "@FILTER_NAME@.hpp"

#include "complex/DataStructure/DataArray.hpp"
#include "complex/DataStructure/DataGroup.hpp"
#include "simplnx/DataStructure/DataArray.hpp"
#include "simplnx/DataStructure/DataGroup.hpp"

using namespace complex;
using namespace nx::core;

// -----------------------------------------------------------------------------
@FILTER_NAME@::@FILTER_NAME@(DataStructure& dataStructure, const IFilter::MessageHandler& mesgHandler, const std::atomic_bool& shouldCancel, @FILTER_NAME@InputValues* inputValues)
Expand Down Expand Up @@ -34,7 +34,7 @@ Result<> @FILTER_NAME@::operator()()
* GenerateIPFColors is one example
*
* If you need to determine what kind of array you have (Int32Array, Float32Array, etc)
* look to the ExecuteDataFunction() in complex/Utilities/FilterUtilities.hpp template
* look to the ExecuteDataFunction() in simplnx/Utilities/FilterUtilities.hpp template
* function to help with that code.
* An Example algorithm class is `CombineAttributeArrays` and `RemoveFlaggedVertices`
*
Expand Down
8 changes: 4 additions & 4 deletions Tools/complex_algorithm.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

#include "@PLUGIN_NAME@/@PLUGIN_NAME@_export.hpp"

#include "complex/DataStructure/DataPath.hpp"
#include "complex/DataStructure/DataStructure.hpp"
#include "complex/Filter/IFilter.hpp"
#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/DataStructure/DataStructure.hpp"
#include "simplnx/Filter/IFilter.hpp"
@PARAMETER_INCLUDES@

/**
* This is example code to put in the Execute Method of the filter.
@EXECUTE_EXAMPLE_CODE@*/

namespace complex
namespace nx::core
{

struct @PLUGIN_NAME_UPPER@_EXPORT @FILTER_NAME@InputValues
Expand Down
37 changes: 31 additions & 6 deletions Tools/complex_filter.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include "@PLUGIN_NAME@/Filters/Algorithms/@ALGORITHM_NAME@.hpp"

#include "complex/DataStructure/DataPath.hpp"
#include "complex/Filter/Actions/EmptyAction.hpp"
#include "simplnx/DataStructure/DataPath.hpp"
#include "simplnx/Filter/Actions/EmptyAction.hpp"
@PARAMETER_INCLUDES@
using namespace complex;
using namespace nx::core;

namespace complex
namespace nx::core
{
//------------------------------------------------------------------------------
std::string @FILTER_NAME@::name() const
Expand Down Expand Up @@ -92,7 +92,7 @@ IFilter::PreflightResult @FILTER_NAME@::preflightImpl(const DataStructure& dataS
// If your filter is making structural changes to the DataStructure then the filter
// is going to create OutputActions subclasses that need to be returned. This will
// store those actions.
complex::Result<OutputActions> resultOutputActions;
nx::core::Result<OutputActions> resultOutputActions;

// If your filter is going to pass back some `preflight updated values` then this is where you
// would create the code to store those values in the appropriate object. Note that we
Expand Down Expand Up @@ -133,4 +133,29 @@ Result<> @FILTER_NAME@::executeImpl(DataStructure& dataStructure, const Argument

return @ALGORITHM_NAME@(dataStructure, messageHandler, shouldCancel, &inputValues)();
}
} // namespace complex

namespace
{
namespace SIMPL
{
@PARAMETER_JSON_CONSTANTS@
} // namespace SIMPL
} // namespace


//------------------------------------------------------------------------------
Result<Arguments> @FILTER_NAME@::FromSIMPLJson(const nlohmann::json& json)
{
Arguments args = @FILTER_NAME@().getDefaultArguments();

std::vector<Result<>> results;

@PARAMETER_JSON_CONVERSION@

Result<> conversionResult = MergeResults(std::move(results));

return ConvertResultTo<Arguments>(std::move(conversionResult), std::move(args));
}


} // namespace nx::core
15 changes: 11 additions & 4 deletions Tools/complex_filter.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

#include "@PLUGIN_NAME@/@PLUGIN_NAME@_export.hpp"

#include "complex/Filter/FilterTraits.hpp"
#include "complex/Filter/IFilter.hpp"
#include "simplnx/Filter/FilterTraits.hpp"
#include "simplnx/Filter/IFilter.hpp"

namespace complex
namespace nx::core
{
/**
* @class @FILTER_NAME@
Expand All @@ -25,6 +25,13 @@ public:

// Parameter Keys
@PARAMETER_KEYS@
/**
* @brief Reads SIMPL json and converts it simplnx Arguments.
* @param json
* @return Result<Arguments>
*/
static Result<Arguments> FromSIMPLJson(const nlohmann::json& json);

/**
* @brief Returns the name of the filter.
* @return
Expand Down Expand Up @@ -92,5 +99,5 @@ protected:
};
} // namespace complex

COMPLEX_DEF_FILTER_TRAITS(complex, @FILTER_NAME@, "@UUID@");
SIMPLNX_DEF_FILTER_TRAITS(nx::core, @FILTER_NAME@, "@UUID@");
/* LEGACY UUID FOR THIS FILTER @OLD_UUID@ */
2 changes: 1 addition & 1 deletion Tools/unit_test_filter.cpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "@PLUGIN_NAME@/Filters/@FILTER_NAME@.hpp"
#include "@PLUGIN_NAME@/@PLUGIN_NAME@_test_dirs.hpp"

using namespace complex;
using namespace nx::core;

TEST_CASE("@PLUGIN_NAME@::@FILTER_NAME@: Valid Filter Execution","[@PLUGIN_NAME@][@FILTER_NAME@][.][UNIMPLEMENTED][!mayfail]")
{
Expand Down

0 comments on commit ec4aa27

Please sign in to comment.