Skip to content

Commit

Permalink
Change Example filter 1 input file parameter to not accept all extens…
Browse files Browse the repository at this point in the history
…ions
  • Loading branch information
jmarquisbq authored and imikejackson committed Apr 17, 2024
1 parent 925781a commit 26ffcb9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 16 additions & 10 deletions src/Plugins/SimplnxCore/wrapping/python/simplnxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ PYBIND11_MODULE(simplnx, mod)
parameters.def("insert_linkable_parameter", &PyInsertLinkableParameter<ChoicesParameter>);
parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, BoolParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); });
parameters.def("link_parameters", [](Parameters& self, std::string groupKey, std::string childKey, ChoicesParameter::ValueType value) { self.linkParameters(groupKey, childKey, value); });
parameters.def("__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal);
parameters.def(
"__getitem__", [](Parameters& self, std::string_view key) { return self.at(key).get(); }, py::return_value_policy::reference_internal);

py::class_<IArrayThreshold, std::shared_ptr<IArrayThreshold>> iArrayThreshold(mod, "IArrayThreshold");

Expand Down Expand Up @@ -643,7 +644,8 @@ PYBIND11_MODULE(simplnx, mod)
},
"Returns true if there is a DataStructure object at the given path");

dataStructure.def("exists", [](DataStructure& self, const DataPath& path) { return (nullptr != self.getData(path)); }, "Returns true if there is a DataStructure object at the given path");
dataStructure.def(
"exists", [](DataStructure& self, const DataPath& path) { return (nullptr != self.getData(path)); }, "Returns true if there is a DataStructure object at the given path");
dataStructure.def("hierarchy_to_str", [](DataStructure& self) {
std::stringstream ss;
self.exportHierarchyAsText(ss);
Expand Down Expand Up @@ -1339,10 +1341,12 @@ PYBIND11_MODULE(simplnx, mod)
},
"name"_a, "path"_a);
pipeline.def("execute", &ExecutePipeline);
pipeline.def("__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal);
pipeline.def(
"__getitem__", [](Pipeline& self, Pipeline::index_type index) { return self.at(index); }, py::return_value_policy::reference_internal);
pipeline.def("__len__", &Pipeline::size);
pipeline.def("size", &Pipeline::size);
pipeline.def("__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>());
pipeline.def(
"__iter__", [](Pipeline& self) { return py::make_iterator(self.begin(), self.end()); }, py::keep_alive<0, 1>());
pipeline.def(
"insert",
[internals](Pipeline& self, Pipeline::index_type index, const IFilter& filter, const py::dict& args) {
Expand All @@ -1356,12 +1360,14 @@ PYBIND11_MODULE(simplnx, mod)
pipeline.def("remove", &Pipeline::removeAt, "index"_a);

pipelineFilter.def("get_args", [internals](PipelineFilter& self) { return ConvertArgsToDict(*internals, self.getParameters(), self.getArguments()); });
pipelineFilter.def("set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a);
pipelineFilter.def("get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal);
pipelineFilter.def("name", [](PipelineFilter& self) { return self.getFilter()->name(); }, "Returns the C++ name of the filter");
pipelineFilter.def("human_name", [](PipelineFilter& self) { return self.getFilter()->humanName(); }, "Returns the human facing name of the filter");


pipelineFilter.def(
"set_args", [internals](PipelineFilter& self, py::dict& args) { self.setArguments(ConvertDictToArgs(*internals, self.getParameters(), args)); }, "args"_a);
pipelineFilter.def(
"get_filter", [](PipelineFilter& self) { return self.getFilter(); }, py::return_value_policy::reference_internal);
pipelineFilter.def(
"name", [](PipelineFilter& self) { return self.getFilter()->name(); }, "Returns the C++ name of the filter");
pipelineFilter.def(
"human_name", [](PipelineFilter& self) { return self.getFilter()->humanName(); }, "Returns the human facing name of the filter");

py::class_<PyFilter, IFilter> pyFilter(mod, "PyFilter");
pyFilter.def(py::init<>([](py::object object) { return std::make_unique<PyFilter>(std::move(object)); }));
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/TestOne/src/TestOne/Filters/ExampleFilter1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ Parameters ExampleFilter1::parameters() const
params.insert(std::make_unique<FileSystemPathParameter>(k_InputDir_Key, "Input Directory", "Example input directory help text", "Data", FileSystemPathParameter::ExtensionsType{},
FileSystemPathParameter::PathType::InputDir));
params.insert(std::make_unique<FileSystemPathParameter>(k_InputFile_Key, "Input File", "Example input file help text", "/opt/local/bin/ninja", FileSystemPathParameter::ExtensionsType{},
FileSystemPathParameter::PathType::InputFile, true));
params.insert(std::make_unique<FileSystemPathParameter>(k_OutputDir_Key, "Ouptut Directory", "Example output directory help text", "Output Data", FileSystemPathParameter::ExtensionsType{},
FileSystemPathParameter::PathType::InputFile, false));
params.insert(std::make_unique<FileSystemPathParameter>(k_OutputDir_Key, "Output Directory", "Example output directory help text", "Output Data", FileSystemPathParameter::ExtensionsType{},
FileSystemPathParameter::PathType::OutputDir));
params.insert(std::make_unique<FileSystemPathParameter>(k_OutputFile_Key, "Output File", "Example output file help text", "", FileSystemPathParameter::ExtensionsType{},
FileSystemPathParameter::PathType::OutputFile));
Expand Down

0 comments on commit 26ffcb9

Please sign in to comment.